﻿#include "MainDialogs.h"
#include "../../MirObjects/MapObject.h"
#include "../../../Shared/Functions/RegexFunctions.h"
#include "../../../Shared/Globals.h"
#include "../../MirGraphics/MLibrary.h"
#include "../../MirSounds/SoundManager.h"
#include "../../KeyBindSettings.h"
#include "../../Forms/Client.CMain.h"
#include "../../../Shared/Language.h"
#include "../GameScene.h"
#include "../../../Shared/Data/Stat.h"
#include "../../../Shared/ClientPackets.h"
#include "../../MirNetwork/Network.h"
#include "../../../Shared/Functions/Functions.h"
#include "../../MirControls/MirMessageBox.h"
#include "GroupDialog.h"
#include "../../MirObjects/PlayerObject.h"
#include "../../MirObjects/NPCObject.h"
#include "../../MirGraphics/DXManager.h"

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirNetwork;
using namespace Client::MirObjects;
using namespace Client::MirSounds;
using namespace SlimDX;
using namespace SlimDX::Direct3D9;
namespace S = ServerPackets;
namespace C = ClientPackets;
using Effect = Client::MirObjects::Effect;
using namespace Client::MirScenes::Dialogs;

namespace Client::MirScenes::Dialogs
{

    UserObject *MainDialog::getUser()
    {
        return MapObject::User;
    }

    void MainDialog::setUser(UserObject *value)
    {
        MapObject::User = value;
    }

    bool MainDialog::getHPOnly() const
    {
        return getUser() != nullptr && getUser()->Class == MirClass::Warrior && getUser()->Level < 26;
    }

    MainDialog::MainDialog()
    {
        setIndex(Settings::Resolution == 800 ? 0 : Settings::Resolution == 1024 ? 1 : 2);
        setLibrary(Libraries::Prguse);
        Point tempVar(((Settings::ScreenWidth / 2) - (getSize()->Width / 2)), Settings::ScreenHeight - getSize()->Height);
        setLocation(&tempVar);
        setPixelDetect(true);

        LeftCap = new MirImageControl();
        LeftCap->setIndex(12);
        LeftCap->setLibrary(Libraries::Prguse);
        Point tempVar2(-67, this->getSize()->Height - 96);
        LeftCap->setLocation(&tempVar2);
        LeftCap->setParent(this);
        LeftCap->setVisible(false);
        RightCap = new MirImageControl();
        RightCap->setIndex(13);
        RightCap->setLibrary(Libraries::Prguse);
        Point tempVar3(1024, this->getSize()->Height - 104);
        RightCap->setLocation(&tempVar3);
        RightCap->setParent(this);
        RightCap->setVisible(false);

        if (Settings::Resolution > 1024)
        {
            LeftCap->setVisible(true);
            RightCap->setVisible(true);
        }

        InventoryButton = new MirButton();
        InventoryButton->setHoverIndex(1904);
        InventoryButton->setIndex(1903);
        InventoryButton->setLibrary(Libraries::Prguse);
        Point tempVar4(this->getSize()->Width - 96, 76);
        InventoryButton->setLocation(&tempVar4);
        InventoryButton->setParent(this);
        InventoryButton->setPressedIndex(1905);
        InventoryButton->setSound(SoundList::ButtonA);
        InventoryButton->setHint(std::string::Format(GameLanguage::Inventory, CMain::InputKeys->GetKey(KeybindOptions::Inventory)));
        InventoryButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->InventoryDialog->getVisible())
            {
                GameScene::Scene->InventoryDialog->Hide();
            }
            else
            {
                GameScene::Scene->InventoryDialog->Show();
            }
        };

        CharacterButton = new MirButton();
        CharacterButton->setHoverIndex(1901);
        CharacterButton->setIndex(1900);
        CharacterButton->setLibrary(Libraries::Prguse);
        Point tempVar5(this->getSize()->Width - 119, 76);
        CharacterButton->setLocation(&tempVar5);
        CharacterButton->setParent(this);
        CharacterButton->setPressedIndex(1902);
        CharacterButton->setSound(SoundList::ButtonA);
        CharacterButton->setHint(std::string::Format(GameLanguage::Character, CMain::InputKeys->GetKey(KeybindOptions::Equipment)));
        CharacterButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->CharacterDialog->getVisible() && GameScene::Scene->CharacterDialog->CharacterPage->getVisible())
            {
                GameScene::Scene->CharacterDialog->Hide();
            }
            else
            {
                GameScene::Scene->CharacterDialog->Show();
                GameScene::Scene->CharacterDialog->ShowCharacterPage();
            }
        };

        SkillButton = new MirButton();
        SkillButton->setHoverIndex(1907);
        SkillButton->setIndex(1906);
        SkillButton->setLibrary(Libraries::Prguse);
        Point tempVar6(this->getSize()->Width - 73, 76);
        SkillButton->setLocation(&tempVar6);
        SkillButton->setParent(this);
        SkillButton->setPressedIndex(1908);
        SkillButton->setSound(SoundList::ButtonA);
        SkillButton->setHint(std::string::Format(GameLanguage::Skills, CMain::InputKeys->GetKey(KeybindOptions::Skills)));
        SkillButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->CharacterDialog->getVisible() && GameScene::Scene->CharacterDialog->SkillPage->getVisible())
            {
                GameScene::Scene->CharacterDialog->Hide();
            }
            else
            {
                GameScene::Scene->CharacterDialog->Show();
                GameScene::Scene->CharacterDialog->ShowSkillPage();
            }
        };

        QuestButton = new MirButton();
        QuestButton->setHoverIndex(1910);
        QuestButton->setIndex(1909);
        QuestButton->setLibrary(Libraries::Prguse);
        Point tempVar7(this->getSize()->Width - 50, 76);
        QuestButton->setLocation(&tempVar7);
        QuestButton->setParent(this);
        QuestButton->setPressedIndex(1911);
        QuestButton->setSound(SoundList::ButtonA);
        QuestButton->setHint(std::string::Format(GameLanguage::Quests, CMain::InputKeys->GetKey(KeybindOptions::Quests)));
        QuestButton->Click += [&] (o, e)
        {
            if (!GameScene::Scene->QuestLogDialog->getVisible())
            {
                GameScene::Scene->QuestLogDialog->Show();
            }
            else
            {
                GameScene::Scene->QuestLogDialog->Hide();
            }
        };

        OptionButton = new MirButton();
        OptionButton->setHoverIndex(1913);
        OptionButton->setIndex(1912);
        OptionButton->setLibrary(Libraries::Prguse);
        Point tempVar8(this->getSize()->Width - 27, 76);
        OptionButton->setLocation(&tempVar8);
        OptionButton->setParent(this);
        OptionButton->setPressedIndex(1914);
        OptionButton->setSound(SoundList::ButtonA);
        OptionButton->setHint(std::string::Format(GameLanguage::Options, CMain::InputKeys->GetKey(KeybindOptions::Options)));
        OptionButton->Click += [&] (o, e)
        {
            if (!GameScene::Scene->OptionDialog->getVisible())
            {
                GameScene::Scene->OptionDialog->Show();
            }
            else
            {
                GameScene::Scene->OptionDialog->Hide();
            }
        };

        MenuButton = new MirButton();
        MenuButton->setHoverIndex(1961);
        MenuButton->setIndex(1960);
        MenuButton->setLibrary(Libraries::Prguse);
        Point tempVar9(this->getSize()->Width - 55, 35);
        MenuButton->setLocation(&tempVar9);
        MenuButton->setParent(this);
        MenuButton->setPressedIndex(1962);
        MenuButton->setSound(SoundList::ButtonC);
        MenuButton->setHint(GameLanguage::Menu);
        MenuButton->Click += [&] (o, e)
        {
            if (!GameScene::Scene->MenuDialog->getVisible())
            {
                GameScene::Scene->MenuDialog->Show();
            }
            else
            {
                GameScene::Scene->MenuDialog->Hide();
            }
        };

        GameShopButton = new MirButton();
        GameShopButton->setHoverIndex(827);
        GameShopButton->setIndex(826);
        GameShopButton->setLibrary(Libraries::Prguse);
        Point tempVar10(this->getSize()->Width - 105, 35);
        GameShopButton->setLocation(&tempVar10);
        GameShopButton->setParent(this);
        GameShopButton->setPressedIndex(828);
        GameShopButton->setSound(SoundList::ButtonC);
        GameShopButton->setHint(std::string::Format(GameLanguage::GameShop, CMain::InputKeys->GetKey(KeybindOptions::GameShop)));
        GameShopButton->Click += [&] (o, e)
        {
            if (!GameScene::Scene->GameShopDialog->getVisible())
            {
                GameScene::Scene->GameShopDialog->Show();
            }
            else
            {
                GameScene::Scene->GameShopDialog->Hide();
            }
        };

        HealthOrb = new MirControl();
        HealthOrb->setParent(this);
        Point tempVar11(0, 30);
        HealthOrb->setLocation(&tempVar11);
        HealthOrb->setNotControl(true);

        HealthOrb->BeforeDraw += HealthOrb_BeforeDraw;

        HealthLabel = new MirLabel();
        HealthLabel->setAutoSize(true);
        Point tempVar12(0, 27);
        HealthLabel->setLocation(&tempVar12);
        HealthLabel->setParent(HealthOrb);
        HealthLabel->SizeChanged->addListener("Label_SizeChanged", [&] (std::any sender, System::EventArgs e) {Label_SizeChanged(sender, e);});

        ManaLabel = new MirLabel();
        ManaLabel->setAutoSize(true);
        Point tempVar13(0, 42);
        ManaLabel->setLocation(&tempVar13);
        ManaLabel->setParent(HealthOrb);
        ManaLabel->SizeChanged->addListener("Label_SizeChanged", [&] (std::any sender, System::EventArgs e) {Label_SizeChanged(sender, e);});

        TopLabel = new MirLabel();
        Size tempVar14(85, 30);
        TopLabel->setSize(&tempVar14);
        TopLabel->setDrawFormat(TextFormatFlags::HorizontalCenter);
        Point tempVar15(9, 20);
        TopLabel->setLocation(&tempVar15);
        TopLabel->setParent(HealthOrb);

        BottomLabel = new MirLabel();
        Size tempVar16(85, 30);
        BottomLabel->setSize(&tempVar16);
        BottomLabel->setDrawFormat(TextFormatFlags::HorizontalCenter);
        Point tempVar17(9, 50);
        BottomLabel->setLocation(&tempVar17);
        BottomLabel->setParent(HealthOrb);

        LevelLabel = new MirLabel();
        LevelLabel->setAutoSize(true);
        LevelLabel->setParent(this);
        Point tempVar18(5, 108);
        LevelLabel->setLocation(&tempVar18);

        CharacterName = new MirLabel();
        CharacterName->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::VerticalCenter);
        CharacterName->setParent(this);
        Point tempVar19(6, 120);
        CharacterName->setLocation(&tempVar19);
        Size tempVar20(90, 16);
        CharacterName->setSize(&tempVar20);


        ExperienceBar = new MirImageControl();
        ExperienceBar->setIndex(Settings::Resolution != 800 ? 8 : 7);
        ExperienceBar->setLibrary(Libraries::Prguse);
        Point tempVar21(9, 143);
        ExperienceBar->setLocation(&tempVar21);
        ExperienceBar->setParent(this);
        ExperienceBar->setDrawImage(false);
        ExperienceBar->setNotControl(true);
        ExperienceBar->BeforeDraw += ExperienceBar_BeforeDraw;

        ExperienceLabel = new MirLabel();
        ExperienceLabel->setAutoSize(true);
        ExperienceLabel->setParent(ExperienceBar);
        ExperienceLabel->setNotControl(true);

        GoldLabel = new MirLabel();
        GoldLabel->setDrawFormat(TextFormatFlags::VerticalCenter);
        System::Drawing::Font tempVar22(Settings::FontName, 8.0F);
        GoldLabel->setFont(&tempVar22);
        Point tempVar23(this->getSize()->Width - 105, 119);
        GoldLabel->setLocation(&tempVar23);
        GoldLabel->setParent(this);
        Size tempVar24(99, 13);
        GoldLabel->setSize(&tempVar24);
        GoldLabel->setSound(SoundList::Gold);
        GoldLabel->Click += [&] (o, e)
        {
            if (GameScene::SelectedCell == nullptr)
            {
                GameScene::PickedUpGold = !GameScene::PickedUpGold && GameScene::Gold > 0;
            }
        };



        WeightBar = new MirImageControl();
        WeightBar->setIndex(76);
        WeightBar->setLibrary(Libraries::Prguse);
        Point tempVar25(this->getSize()->Width - 105, 103);
        WeightBar->setLocation(&tempVar25);
        WeightBar->setParent(this);
        WeightBar->setDrawImage(false);
        WeightBar->setNotControl(true);
        WeightBar->BeforeDraw += WeightBar_BeforeDraw;

        WeightLabel = new MirLabel();
        WeightLabel->setParent(this);
        Point tempVar26(this->getSize()->Width - 105, 101);
        WeightLabel->setLocation(&tempVar26);
        Size tempVar27(40, 14);
        WeightLabel->setSize(&tempVar27);

        SpaceLabel = new MirLabel();
        SpaceLabel->setParent(this);
        Point tempVar28(this->getSize()->Width - 30, 101);
        SpaceLabel->setLocation(&tempVar28);
        Size tempVar29(26, 14);
        SpaceLabel->setSize(&tempVar29);

        CustomButton1 = new MirButton();
        CustomButton1->setIndex(2164);
        CustomButton1->setHoverIndex(2165);
        CustomButton1->setPressedIndex(2166);
        CustomButton1->setLibrary(Libraries::Prguse);
        CustomButton1->setParent(this);
        Point tempVar30(this->getSize()->Width - 160, 65);
        CustomButton1->setLocation(&tempVar30);
        Size tempVar31(20, 20);
        CustomButton1->setSize(&tempVar31);
        CustomButton1->setSound(SoundList::ButtonA);
        CustomButton1->setVisible(!Settings::ModeView);
        CustomButton1->Click += [&] (o, e)
        {
            GameScene::Scene->CustomPanel1->Toggle();
        };

        CustomButton2 = new MirButton();
        CustomButton2->setIndex(2167);
        CustomButton2->setHoverIndex(2168);
        CustomButton2->setPressedIndex(2169);
        CustomButton2->setLibrary(Libraries::Prguse);
        CustomButton2->setParent(this);
        Point tempVar32(this->getSize()->Width - 160, 90);
        CustomButton2->setLocation(&tempVar32);
        Size tempVar33(20, 20);
        CustomButton2->setSize(&tempVar33);
        CustomButton2->setSound(SoundList::ButtonA);
        CustomButton2->Click += [&] (o, e)
        {
            C::CallNPC *tempVar34 = new C::CallNPC();
            tempVar34->ObjectID = std::numeric_limits<unsigned int>::max();
            Network::Enqueue(tempVar34);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar34' statement was not added since tempVar34 was passed to a method or constructor. Handle memory management manually.
        };

        AModeLabel = new MirLabel();
        AModeLabel->setAutoSize(true);
        AModeLabel->setForeColour(Color::Yellow);
        AModeLabel->setOutLineColour(Color::Black);
        AModeLabel->setParent(this);
        Point tempVar35(Settings::Resolution != 800 ? 899 : 675, Settings::Resolution != 800 ? -448 : -280);
        AModeLabel->setLocation(&tempVar35);
        AModeLabel->setVisible(Settings::ModeView);

        PModeLabel = new MirLabel();
        PModeLabel->setAutoSize(true);
        PModeLabel->setForeColour(Color::Orange);
        PModeLabel->setOutLineColour(Color::Black);
        PModeLabel->setParent(this);
        Point tempVar36(230, 125);
        PModeLabel->setLocation(&tempVar36);
        PModeLabel->setVisible(Settings::ModeView);

        SModeLabel = new MirLabel();
        SModeLabel->setAutoSize(true);
        SModeLabel->setForeColour(Color::LimeGreen);
        SModeLabel->setOutLineColour(Color::Black);
        SModeLabel->setParent(this);
        Point tempVar37(Settings::Resolution != 800 ? 899 : 675, Settings::Resolution != 800 ? -463 : -295);
        SModeLabel->setLocation(&tempVar37);
        SModeLabel->setVisible(Settings::ModeView);
    }

    void MainDialog::Process()
    {
        switch (GameScene::Scene->AMode)
        {
            case AttackMode::Peace:
                AModeLabel->setText(GameLanguage::AttackMode_Peace);
                break;
            case AttackMode::Group:
                AModeLabel->setText(GameLanguage::AttackMode_Group);
                break;
            case AttackMode::Guild:
                AModeLabel->setText(GameLanguage::AttackMode_Guild);
                break;
            case AttackMode::EnemyGuild:
                AModeLabel->setText(GameLanguage::AttackMode_EnemyGuild);
                break;
            case AttackMode::RedBrown:
                AModeLabel->setText(GameLanguage::AttackMode_RedBrown);
                break;
            case AttackMode::All:
                AModeLabel->setText(GameLanguage::AttackMode_All);
                break;
        }

        switch (GameScene::Scene->PMode)
        {
            case PetMode::Both:
                PModeLabel->setText(GameLanguage::PetMode_Both);
                break;
            case PetMode::MoveOnly:
                PModeLabel->setText(GameLanguage::PetMode_MoveOnly);
                break;
            case PetMode::AttackOnly:
                PModeLabel->setText(GameLanguage::PetMode_AttackOnly);
                break;
            case PetMode::None:
                PModeLabel->setText(GameLanguage::PetMode_None);
                break;
        }

        switch (Settings::SkillMode)
        {
            case true:
                SModeLabel->setText("[Skill Mode: ~]");
                break;
            case false:
                SModeLabel->setText("[Skill Mode: Ctrl]");
                break;
        }

        if (Settings::HPView)
        {
            HealthLabel->setText(StringHelper::formatSimple("HP {0}/{1}", getUser()->HP, getUser()->Stats[Stat::HP]));
            ManaLabel->setText(getHPOnly() ? "" : StringHelper::formatSimple("MP {0}/{1} ", getUser()->MP, getUser()->Stats[Stat::MP]));
            TopLabel->setText("");
            BottomLabel->setText("");
        }
        else
        {
            if (getHPOnly())
            {
                TopLabel->setText(StringHelper::formatSimple("{0}\n" + "--", getUser()->HP));
                BottomLabel->setText(StringHelper::formatSimple("{0}", getUser()->Stats[Stat::HP]));
            }
            else
            {
                TopLabel->setText(StringHelper::formatSimple(" {0}    {1} \n" + "---------------", getUser()->HP, getUser()->MP));
                BottomLabel->setText(StringHelper::formatSimple(" {0}    {1} ", getUser()->Stats[Stat::HP], getUser()->Stats[Stat::MP]));
            }
            HealthLabel->setText("");
            ManaLabel->setText("");
        }

        LevelLabel->setText(std::to_string(getUser()->Level));
        ExperienceLabel->setText(std::string::Format("{0:#0.##%}", getUser()->Experience / static_cast<double>(getUser()->MaxExperience)));
        Point tempVar((ExperienceBar->getSize()->Width / 2) - 20, -10);
        ExperienceLabel->setLocation(&tempVar);
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
        GoldLabel->setText(GameScene::Gold.ToString("###,###,##0"));
        CharacterName->setText(getUser()->Name);
        SpaceLabel->setText(std::to_string(getUser()->Inventory.Count([&] (std::any t)
        {
            return t == nullptr;
        })));
        WeightLabel->setText(std::to_string(MapObject::User->Stats[Stat::BagWeight] - MapObject::User->CurrentBagWeight));
    }

    void MainDialog::Label_SizeChanged(std::any sender, EventArgs *e)
    {
        MirLabel *l = dynamic_cast<MirLabel*>(sender);
        if (!(l != nullptr))
        {
            return;
        }

        Point tempVar(50 - (l->getSize()->Width / 2), l->getLocation()->Y);
        l->setLocation(&tempVar);
    }

    void MainDialog::HealthOrb_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (Libraries::Prguse == nullptr)
        {
            return;
        }

        int height;
        if (getUser() != nullptr && getUser()->HP != getUser()->Stats[Stat::HP])
        {
            height = static_cast<int>(80 * getUser()->HP / static_cast<float>(getUser()->Stats[Stat::HP]));
        }
        else
        {
            height = 80;
        }

        if (height < 0)
        {
            height = 0;
        }
        if (height > 80)
        {
            height = 80;
        }

        int orbImage = 4;

        bool hpOnly = false;

        if (getHPOnly())
        {
            hpOnly = true;
            orbImage = 6;
        }

        Rectangle *r = new Rectangle(0, 80 - height, hpOnly ? 100 : 50, height);
        Point tempVar(((Settings::ScreenWidth / 2) - (getSize()->Width / 2)), HealthOrb->getDisplayLocation()->Y + 80 - height);
        Libraries::Prguse->Draw(orbImage, r, &tempVar, Color::White, false);

        if (hpOnly)
        {
//C# TO C++ CONVERTER TODO TASK: A 'delete r' statement was not added since r was passed to a method or constructor. Handle memory management manually.
            return;
        }

        if (getUser()->MP != getUser()->Stats[Stat::MP])
        {
            height = static_cast<int>(80 * getUser()->MP / static_cast<float>(getUser()->Stats[Stat::MP]));
        }
        else
        {
            height = 80;
        }

        if (height < 0)
        {
            height = 0;
        }
        if (height > 80)
        {
            height = 80;
        }
        r = new Rectangle(51, 80 - height, 50, height);

        Point tempVar2(((Settings::ScreenWidth / 2) - (getSize()->Width / 2)) + 51, HealthOrb->getDisplayLocation()->Y + 80 - height);
        Libraries::Prguse->Draw(4, r, &tempVar2, Color::White, false);

//C# TO C++ CONVERTER TODO TASK: A 'delete r' statement was not added since r was passed to a method or constructor. Handle memory management manually.
    }

    void MainDialog::ExperienceBar_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (ExperienceBar->getLibrary() == nullptr)
        {
            return;
        }

        double percent = MapObject::User->Experience / static_cast<double>(MapObject::User->MaxExperience);
        if (percent > 1)
        {
            percent = 1;
        }
        if (percent <= 0)
        {
            return;
        }

        Rectangle *section = new Rectangle();
        section->Size = new Size(static_cast<int>((ExperienceBar->getSize()->Width - 3) * percent), ExperienceBar->getSize()->Height);

        ExperienceBar->getLibrary()->Draw(ExperienceBar->getIndex(), section, ExperienceBar->getDisplayLocation(), Color::White, false);

//C# TO C++ CONVERTER TODO TASK: A 'delete section' statement was not added since section was passed to a method or constructor. Handle memory management manually.
    }

    void MainDialog::WeightBar_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (WeightBar->getLibrary() == nullptr)
        {
            return;
        }
        double percent = MapObject::User->CurrentBagWeight / static_cast<double>(MapObject::User->Stats[Stat::BagWeight]);
        if (percent > 1)
        {
            percent = 1;
        }
        if (percent <= 0)
        {
            return;
        }

        Rectangle *section = new Rectangle();
        section->Size = new Size(static_cast<int>((WeightBar->getSize()->Width - 2) * percent), WeightBar->getSize()->Height);

        WeightBar->getLibrary()->Draw(WeightBar->getIndex(), section, WeightBar->getDisplayLocation(), Color::White, false);

//C# TO C++ CONVERTER TODO TASK: A 'delete section' statement was not added since section was passed to a method or constructor. Handle memory management manually.
    }

    ChatDialog::ChatDialog()
    {
        setIndex(Settings::Resolution != 800 ? 2221 : 2201);
        setLibrary(Libraries::Prguse);
        Point tempVar(GameScene::Scene->MainDialog->getLocation()->X + 230, Settings::ScreenHeight - 97);
        setLocation(&tempVar);
        setPixelDetect(true);

        KeyPress += ChatPanel_KeyPress;
        KeyDown += ChatPanel_KeyDown;
        MouseWheel += ChatPanel_MouseWheel;

        ChatTextBox = new MirTextBox();
        ChatTextBox->setBackColour(Color::DarkGray);
        ChatTextBox->setForeColour(Color::Black);
        ChatTextBox->setParent(this);
        Size tempVar2(Settings::Resolution != 800 ? 627 : 403, 13);
        ChatTextBox->setSize(&tempVar2);
        Point tempVar3(1, 54);
        ChatTextBox->setLocation(&tempVar3);
        ChatTextBox->setMaxLength(Globals::MaxChatLength);
        ChatTextBox->setVisible(false);
        ChatTextBox->setFont(ChatFont);
        ChatTextBox->TextBox->KeyPress += ChatTextBox_KeyPress;
        ChatTextBox->TextBox->KeyDown += ChatTextBox_KeyDown;
        ChatTextBox->TextBox->KeyUp += ChatTextBox_KeyUp;

        HomeButton = new MirButton();
        HomeButton->setIndex(2018);
        HomeButton->setHoverIndex(2019);
        HomeButton->setLibrary(Libraries::Prguse);
        Point tempVar4(Settings::Resolution != 800 ? 618 : 394, 1);
        HomeButton->setLocation(&tempVar4);
        HomeButton->setParent(this);
        HomeButton->setPressedIndex(2020);
        HomeButton->setSound(SoundList::ButtonA);
        HomeButton->Click += [&] (o, e)
        {
            if (StartIndex == 0)
            {
                return;
            }
            StartIndex = 0;
            Update();
        };


        UpButton = new MirButton();
        UpButton->setIndex(2021);
        UpButton->setHoverIndex(2022);
        UpButton->setLibrary(Libraries::Prguse);
        Point tempVar5(Settings::Resolution != 800 ? 618 : 394, 9);
        UpButton->setLocation(&tempVar5);
        UpButton->setParent(this);
        UpButton->setPressedIndex(2023);
        UpButton->setSound(SoundList::ButtonA);
        UpButton->Click += [&] (o, e)
        {
            if (StartIndex == 0)
            {
                return;
            }
            StartIndex--;
            Update();
        };


        EndButton = new MirButton();
        EndButton->setIndex(2027);
        EndButton->setHoverIndex(2028);
        EndButton->setLibrary(Libraries::Prguse);
        Point tempVar6(Settings::Resolution != 800 ? 618 : 394, 45);
        EndButton->setLocation(&tempVar6);
        EndButton->setParent(this);
        EndButton->setPressedIndex(2029);
        EndButton->setSound(SoundList::ButtonA);
        EndButton->Click += [&] (o, e)
        {
            if (StartIndex == History.size() - 1)
            {
                return;
            }
            StartIndex = History.size() - 1;
            Update();
        };

        DownButton = new MirButton();
        DownButton->setIndex(2024);
        DownButton->setHoverIndex(2025);
        DownButton->setLibrary(Libraries::Prguse);
        Point tempVar7(Settings::Resolution != 800 ? 618 : 394, 39);
        DownButton->setLocation(&tempVar7);
        DownButton->setParent(this);
        DownButton->setPressedIndex(2026);
        DownButton->setSound(SoundList::ButtonA);
        DownButton->Click += [&] (o, e)
        {
            if (StartIndex == History.size() - 1)
            {
                return;
            }
            StartIndex++;
            Update();
        };



        CountBar = new MirImageControl();
        CountBar->setIndex(2012);
        CountBar->setLibrary(Libraries::Prguse);
        Point tempVar8(Settings::Resolution != 800 ? 622 : 398, 16);
        CountBar->setLocation(&tempVar8);
        CountBar->setParent(this);

        PositionBar = new MirButton();
        PositionBar->setIndex(2015);
        PositionBar->setHoverIndex(2016);
        PositionBar->setLibrary(Libraries::Prguse);
        Point tempVar9(Settings::Resolution != 800 ? 619 : 395, 16);
        PositionBar->setLocation(&tempVar9);
        PositionBar->setParent(this);
        PositionBar->setPressedIndex(2017);
        PositionBar->setMovable(true);
        PositionBar->setSound(SoundList::None);
        PositionBar->OnMoving->addListener("PositionBar_OnMoving", std::bind(&ChatDialog::PositionBar_OnMoving, this, std::placeholders::_1, std::placeholders::_2));
    }

    void ChatDialog::SetChatText(const std::string &newText)
    {
        std::string newMsg = ChatTextBox->setText(std::string newMsg = ChatTextBox->getText() + newText);

        if (newMsg.length() > Globals::MaxChatLength)
        {
            return;
        }

        ChatTextBox->setText(newMsg);
        ChatTextBox->SetFocus();
        ChatTextBox->setVisible(true);
        ChatTextBox->TextBox->SelectionLength = 0;
        ChatTextBox->TextBox->SelectionStart = ChatTextBox->getText().length();
    }

    void ChatDialog::ChatTextBox_KeyPress(std::any sender, KeyPressEventArgs *e)
    {
        switch (e->KeyChar)
        {
            case static_cast<char>(Keys->Enter):
                e->Handled = true;
                if (!ChatTextBox->getText().empty())
                {
                    std::string msg = ChatTextBox->getText();

                    if (StringHelper::toUpper(msg) == "@LEVELEFFECT")
                    {
                        Settings::LevelEffect = !Settings::LevelEffect;
                    }

                    if (StringHelper::toUpper(msg) == "@TARGETDEAD")
                    {
                        Settings::TargetDead = !Settings::TargetDead;
                    }

                    C::Chat *tempVar = new C::Chat();
                    tempVar->Message = msg;
                    tempVar->LinkedItems = std::vector<ChatItem*>(LinkedItems);
                    Network::Enqueue(tempVar);

                    if (ChatTextBox->getText()[0] == '/')
                    {
                        std::vector<std::string> parts = StringHelper::split(ChatTextBox->getText(), ' ');
                        if (parts.size() > 0)
                        {
                            LastPM = parts[0];
                        }
                    }

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
                }
                ChatTextBox->setVisible(false);
                ChatTextBox->setText("");
                LinkedItems.clear();
                break;
            case static_cast<char>(Keys->Escape):
                e->Handled = true;
                ChatTextBox->setVisible(false);
                ChatTextBox->setText("");
                LinkedItems.clear();
                break;
        }
    }

    void ChatDialog::PositionBar_OnMoving(std::any sender, MouseEventArgs *e)
    {
        int x = Settings::Resolution != 800 ? 619 : 395;
        int y = PositionBar->getLocation()->Y;
        if (y >= 16 + CountBar->getSize()->Height - PositionBar->getSize()->Height)
        {
            y = 16 + CountBar->getSize()->Height - PositionBar->getSize()->Height;
        }
        if (y < 16)
        {
            y = 16;
        }

        int h = CountBar->getSize()->Height - PositionBar->getSize()->Height;
        h = static_cast<int>((y - 16) / (h / static_cast<float>(History.size() - 1)));

        if (h != StartIndex)
        {
            StartIndex = h;
            Update();
        }

        Point tempVar(x, y);
        PositionBar->setLocation(&tempVar);
    }

    void ChatDialog::ReceiveChat(const std::string &text, ChatType type)
    {
        Color *foreColour, *backColour;

        switch (type)
        {
            case ChatType::Hint:
                backColour = Color::White;
                foreColour = Color::DarkGreen;
                break;
            case ChatType::Announcement:
                backColour = Color::Blue;
                foreColour = Color::White;
                GameScene::Scene->ChatNoticeDialog->ShowNotice(RegexFunctions::CleanChatString(text));
                break;
            case ChatType::LineMessage:
                backColour = Color::Blue;
                foreColour = Color::White;
                break;
            case ChatType::Shout:
                backColour = Color::Yellow;
                foreColour = Color::Black;
                break;
            case ChatType::Shout2:
                backColour = Color::Green;
                foreColour = Color::White;
                break;
            case ChatType::Shout3:
                backColour = Color::Purple;
                foreColour = Color::White;
                break;
            case ChatType::System:
                backColour = Color::Red;
                foreColour = Color::White;
                break;
            case ChatType::System2:
                backColour = Color::DarkRed;
                foreColour = Color::White;
                break;
            case ChatType::Group:
                backColour = Color::White;
                foreColour = Color::Brown;
                break;
            case ChatType::WhisperOut:
                foreColour = Color::CornflowerBlue;
                backColour = Color::White;
                break;
            case ChatType::WhisperIn:
                foreColour = Color::DarkBlue;
                backColour = Color::White;
                break;
            case ChatType::Guild:
                backColour = Color::White;
                foreColour = Color::Green;
                break;
            case ChatType::LevelUp:
                backColour = Color::FromArgb(255, 225, 185, 250);
                foreColour = Color::Blue;
                break;
            case ChatType::Relationship:
                backColour = Color::Transparent;
                foreColour = Color::HotPink;
                break;
            case ChatType::Mentor:
                backColour = Color::White;
                foreColour = Color::Purple;
                break;
            default:
                backColour = Color::White;
                foreColour = Color::Black;
                break;
        }

        std::vector<std::string> chat;

        int chatWidth = Settings::Resolution != 800 ? 614 : 390;
        int index = 0;
        int matchCount = 0;

        for (int i = 1; i < text.length(); i++)
        {
            if (i - index < 0)
            {
                continue;
            }

            if (TextRenderer::MeasureText(CMain::Graphics, text.substr(index, i - index), ChatFont)->Width > chatWidth)
            {
                int offset = i - index;
                int newIndex = i - 1;

                auto itemLinkMatches = RegexFunctions::ChatItemLinks->Matches(text.substr(index))->Cast<Match*>();

                if (itemLinkMatches->Any())
                {
                    auto match = itemLinkMatches->SingleOrDefault([&] (std::any x)
                    {
                        return (x::Index < (i - index)) && (x::Index + x->Length > offset - 1);
                    });

                    if (match != nullptr)
                    {
                        offset = match->Index;
                        newIndex = match->Index;
                    }
                }

                chat.push_back(text.substr(index, offset - 1));
                index = newIndex;
            }
        }

        chat.push_back(text.substr(index, text.length() - index));

        if (StartIndex == History.size() - LineCount)
        {
            StartIndex += chat.size();
        }

        for (int i = 0; i < chat.size(); i++)
        {
            ChatHistory *tempVar = new ChatHistory();
            tempVar->Text = chat[i];
            tempVar->BackColour = backColour;
            tempVar->ForeColour = foreColour;
            tempVar->Type = type;
            FullHistory.push_back(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
        }

        Update();
    }

    void ChatDialog::Update()
    {
        History = std::vector<ChatHistory*>();

        for (int i = 0; i < FullHistory.size(); i++)
        {
            switch (FullHistory[i]->Type)
            {
                case ChatType::Normal:
                case ChatType::LineMessage:
                    if (Settings::FilterNormalChat)
                    {
                        continue;
                    }
                    break;
                case ChatType::WhisperIn:
                case ChatType::WhisperOut:
                    if (Settings::FilterWhisperChat)
                    {
                        continue;
                    }
                    break;
                case ChatType::Shout:
                case ChatType::Shout2:
                case ChatType::Shout3:
                    if (Settings::FilterShoutChat)
                    {
                        continue;
                    }
                    break;
                case ChatType::System:
                case ChatType::System2:
                    if (Settings::FilterSystemChat)
                    {
                        continue;
                    }
                    break;
                case ChatType::Group:
                    if (Settings::FilterGroupChat)
                    {
                        continue;
                    }
                    break;
                case ChatType::Guild:
                    if (Settings::FilterGuildChat)
                    {
                        continue;
                    }
                    break;
            }

            History.push_back(FullHistory[i]);
        }

        for (int i = 0; i < ChatLines.size(); i++)
        {
            ChatLines[i]->Dispose();
        }

        for (int i = 0; i < LinkedItemButtons.size(); i++)
        {
            LinkedItemButtons[i]->Dispose();
        }

        ChatLines.clear();
        LinkedItemButtons.clear();

        if (StartIndex >= History.size())
        {
            StartIndex = History.size() - 1;
        }
        if (StartIndex < 0)
        {
            StartIndex = 0;
        }

        if (History.size() > 1)
        {
            int h = CountBar->getSize()->Height - PositionBar->getSize()->Height;
            h = static_cast<int>((h / static_cast<float>(History.size() - 1)) * StartIndex);
            Point tempVar(Settings::Resolution != 800 ? 619 : 395, 16 + h);
            PositionBar->setLocation(&tempVar);
        }

        int y = 1;

        for (int i = StartIndex; i < History.size(); i++)
        {
            MirLabel *temp = new MirLabel();
            temp->setAutoSize(true);
            temp->setBackColour(History[i]->BackColour);
            temp->setForeColour(History[i]->ForeColour);
            Point tempVar2(1, y);
            temp->setLocation(&tempVar2);
            temp->setOutLine(false);
            temp->setParent(this);
            temp->setText(History[i]->Text);
            temp->setFont(ChatFont);
            temp->MouseWheel += ChatPanel_MouseWheel;
            ChatLines.push_back(temp);

            temp->Click += [&] (o, e)
            {
                MirLabel *l = dynamic_cast<MirLabel*>(o);
                if (!(l != nullptr))
                {
                    return;
                }
    
                std::vector<std::string> parts = l->getText().Split(':', ' ');
                if (parts.empty())
                {
                    return;
                }
    
                std::string name = Regex::Replace(parts[0], "[^A-Za-z0-9]", "");
    
                ChatTextBox->SetFocus();
                ChatTextBox->setText(StringHelper::formatSimple("/{0} ", name));
                ChatTextBox->setVisible(true);
                ChatTextBox->TextBox->SelectionLength = 0;
                ChatTextBox->TextBox->SelectionStart = ChatTextBox->getText().length();
            };

            std::string currentLine = History[i]->Text;

            int oldLength = currentLine.length();

            Capture *capture = nullptr;

            for (auto match : RegexFunctions::ChatItemLinks->Matches(currentLine)->Cast<Match*>().OrderBy([&] (std::any o)
            {
                return o::Index;
            }).ToList())
            {
                try
                {
                    int offSet = oldLength - currentLine.length();

                    capture = match::Groups[1].Captures[0];
                    std::vector<std::string> values = StringHelper::split(capture->Value, '/');
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the .NET String 'Insert' method unless assigning to the string instance:
                    currentLine.erase(capture->Index - 1 - offSet, capture->Length + 2)->Insert(capture->Index - 1 - offSet, values[0]);
                    std::string text = currentLine.substr(0, capture->Index - 1 - offSet) + " ";
                    Size *size = TextRenderer::MeasureText(CMain::Graphics, text, temp->getFont(), temp->getSize(), TextFormatFlags::TextBoxControl);

                    Point tempVar3(size->Width - 10, 0);
                    ChatLink(values[0], std::stoull(values[1]), Functions::Add(temp->getLocation(), &tempVar3));
                }
                catch (const std::runtime_error &ex)
                {
                    //Temporary debug to catch unknown error
                    CMain::SaveError(ex.what());
                    CMain::SaveError(currentLine);
                    CMain::SaveError(capture->Value);

//C# TO C++ CONVERTER TODO TASK: A 'delete temp' statement was not added since temp was passed to a method or constructor. Handle memory management manually.
                    throw;
                }
            }

            temp->setText(currentLine);

            y += 13;
            if (i - StartIndex == LineCount - 1)
            {
//C# TO C++ CONVERTER TODO TASK: A 'delete temp' statement was not added since temp was passed to a method or constructor. Handle memory management manually.
                break;
            }

//C# TO C++ CONVERTER TODO TASK: A 'delete temp' statement was not added since temp was passed to a method or constructor. Handle memory management manually.
        }

    }

    void ChatDialog::ChatLink(const std::string &name, unsigned long long uniqueID, Point *p)
    {
        UserItem *item = GameScene::ChatItemList.FirstOrDefault([&] (std::any x)
        {
            return x->UniqueID == uniqueID;
        });

        if (item != nullptr)
        {
            MirLabel *temp = new MirLabel();
            temp->setAutoSize(true);
            temp->setVisible(true);
            temp->setParent(this);
            temp->setLocation(p);
            temp->setText(name);
            temp->setForeColour(Color::Blue);
            temp->setSound(SoundList::ButtonC);
            temp->setFont(ChatFont);
            temp->setOutLine(false);

            temp->MouseEnter += [&] (o, e)
            {
                temp->setForeColour(Color::Red);
            };
            temp->MouseLeave += [&] (o, e)
            {
                GameScene::Scene->DisposeItemLabel();
                temp->setForeColour(Color::Blue);
            };
            temp->MouseDown += [&] (o, e)
            {
                temp->setForeColour(Color::Blue);
            };
            temp->MouseUp->addListener([&] (o, e)
            {
                temp->setForeColour(Color::Red);
            });

            temp->Click += [&] (o, e)
            {
                GameScene::Scene->CreateItemLabel(item);
            };

            LinkedItemButtons.push_back(temp);

//C# TO C++ CONVERTER TODO TASK: A 'delete temp' statement was not added since temp was passed to a method or constructor. Handle memory management manually.
        }
    }

    void ChatDialog::ChatPanel_KeyDown(std::any sender, KeyEventArgs *e)
    {
        switch (e->KeyCode)
        {
            case Keys->Up:
                if (StartIndex == 0)
                {
                    return;
                }
                StartIndex--;
                break;
            case Keys->Home:
                if (StartIndex == 0)
                {
                    return;
                }
                StartIndex = 0;
                break;
            case Keys->Down:
                if (StartIndex == History.size() - 1)
                {
                    return;
                }
                StartIndex++;
                break;
            case Keys->End:
                if (StartIndex == History.size() - 1)
                {
                    return;
                }
                StartIndex = History.size() - 1;
                break;
            case Keys->PageUp:
                if (StartIndex == 0)
                {
                    return;
                }
                StartIndex -= LineCount;
                break;
            case Keys->PageDown:
                if (StartIndex == History.size() - 1)
                {
                    return;
                }
                StartIndex += LineCount;
                break;
            default:
                return;
        }
        Update();
        e->Handled = true;
    }

    void ChatDialog::ChatPanel_KeyPress(std::any sender, KeyPressEventArgs *e)
    {
        switch (e->KeyChar)
        {
            case '@':
            case '!':
            case ' ':
            case static_cast<char>(Keys->Enter):
                ChatTextBox->SetFocus();
                if (e->KeyChar == '!')
                {
                    ChatTextBox->setText("!");
                }
                if (e->KeyChar == '@')
                {
                    ChatTextBox->setText("@");
                }
                if (ChatPrefix != "")
                {
                    ChatTextBox->setText(ChatPrefix);
                }

                ChatTextBox->setVisible(true);
                ChatTextBox->TextBox->SelectionLength = 0;
                ChatTextBox->TextBox->SelectionStart = ChatTextBox->getText().length();
                e->Handled = true;
                break;
            case '/':
                ChatTextBox->SetFocus();
                ChatTextBox->setText(LastPM + " ");
                ChatTextBox->setVisible(true);
                ChatTextBox->TextBox->SelectionLength = 0;
                ChatTextBox->TextBox->SelectionStart = ChatTextBox->getText().length();
                e->Handled = true;
                break;
        }
    }

    void ChatDialog::ChatPanel_MouseWheel(std::any sender, MouseEventArgs *e)
    {
        int count = e->Delta / SystemInformation::MouseWheelScrollDelta;

        if (StartIndex == 0 && count >= 0)
        {
            return;
        }
        if (StartIndex == History.size() - 1 && count <= 0)
        {
            return;
        }

        StartIndex -= count;
        Update();
    }

    void ChatDialog::ChatTextBox_KeyUp(std::any sender, KeyEventArgs *e)
    {
        CMain::Shift = e->Shift;
        CMain::Alt = e->Alt;
        CMain::Ctrl = e->Control;

        switch (e->KeyCode)
        {
            case Keys->F1:
            case Keys->F2:
            case Keys->F3:
            case Keys->F4:
            case Keys->F5:
            case Keys->F6:
            case Keys->F7:
            case Keys->F8:
            case Keys->F9:
            case Keys->F10:
            case Keys->F11:
            case Keys->F12:
            case Keys->Tab:
                CMain::CMain_KeyUp(sender, e);
                break;

        }
    }

    void ChatDialog::ChatTextBox_KeyDown(std::any sender, KeyEventArgs *e)
    {
        CMain::Shift = e->Shift;
        CMain::Alt = e->Alt;
        CMain::Ctrl = e->Control;

        switch (e->KeyCode)
        {
            case Keys->F1:
            case Keys->F2:
            case Keys->F3:
            case Keys->F4:
            case Keys->F5:
            case Keys->F6:
            case Keys->F7:
            case Keys->F8:
            case Keys->F9:
            case Keys->F10:
            case Keys->F11:
            case Keys->F12:
            case Keys->Tab:
                CMain::CMain_KeyDown(sender, e);
                break;

        }
    }

    void ChatDialog::ChangeSize()
    {
        if (++WindowSize >= 3)
        {
            WindowSize = 0;
        }

        int y = getDisplayRectangle()->Bottom;
        switch (WindowSize)
        {
            case 0:
                LineCount = 4;
                setIndex(Settings::Resolution != 800 ? 2221 : 2201);
                CountBar->setIndex(2012);
                Point tempVar(Settings::Resolution != 800 ? 618 : 394, 39);
                DownButton->setLocation(&tempVar);
                Point tempVar2(Settings::Resolution != 800 ? 618 : 394, 45);
                EndButton->setLocation(&tempVar2);
                Point tempVar3(1, 54);
                ChatTextBox->setLocation(&tempVar3);
                break;
            case 1:
                LineCount = 7;
                setIndex(Settings::Resolution != 800 ? 2224 : 2204);
                CountBar->setIndex(2013);
                Point tempVar4(Settings::Resolution != 800 ? 618 : 394, 39 + 48);
                DownButton->setLocation(&tempVar4);
                Point tempVar5(Settings::Resolution != 800 ? 618 : 394, 45 + 48);
                EndButton->setLocation(&tempVar5);
                Point tempVar6(1, 54 + 48);
                ChatTextBox->setLocation(&tempVar6);
                break;
            case 2:
                LineCount = 11;
                setIndex(Settings::Resolution != 800 ? 2227 : 2207);
                CountBar->setIndex(2014);
                Point tempVar7(Settings::Resolution != 800 ? 618 : 394, 39 + 96);
                DownButton->setLocation(&tempVar7);
                Point tempVar8(Settings::Resolution != 800 ? 618 : 394, 45 + 96);
                EndButton->setLocation(&tempVar8);
                Point tempVar9(1, 54 + 96);
                ChatTextBox->setLocation(&tempVar9);
                break;
        }

        Point tempVar10(getLocation()->X, y - getSize()->Height);
        setLocation(&tempVar10);

        UpdateBackground();

        Update();
    }

    void ChatDialog::UpdateBackground()
    {
        int offset = Transparent ? 1 : 0;

        switch (WindowSize)
        {
            case 0:
                setIndex(Settings::Resolution != 800 ? 2221 : 2201);
                break;
            case 1:
                setIndex(Settings::Resolution != 800 ? 2224 : 2204);
                break;
            case 2:
                setIndex(Settings::Resolution != 800 ? 2227 : 2207);
                break;
        }

        setIndex(getIndex() - offset);
    }

    ChatControlBar::ChatControlBar()
    {
        setIndex(Settings::Resolution != 800 ? 2034 : 2035);
        setLibrary(Libraries::Prguse);
        Point tempVar(GameScene::Scene->MainDialog->getLocation()->X + 230, Settings::ScreenHeight - 112);
        setLocation(&tempVar);

        SizeButton = new MirButton();
        SizeButton->setIndex(2057);
        SizeButton->setHoverIndex(2058);
        SizeButton->setPressedIndex(2059);
        SizeButton->setLibrary(Libraries::Prguse);
        SizeButton->setParent(this);
        Point tempVar2(Settings::Resolution != 800 ? 574 : 350, 1);
        SizeButton->setLocation(&tempVar2);
        SizeButton->setVisible(true);
        SizeButton->setSound(SoundList::ButtonA);
        SizeButton->setHint(GameLanguage::Size);
        SizeButton->Click += [&] (o, e)
        {
            GameScene::Scene->ChatDialog->ChangeSize();
            Point tempVar3(getLocation()->X, GameScene::Scene->ChatDialog->getDisplayRectangle()->Top - getSize()->Height);
            setLocation(&tempVar3);
            if (GameScene::Scene->BeltDialog->getIndex() == 1932)
            {
                Point tempVar4(GameScene::Scene->MainDialog->getLocation()->X + 230, getLocation()->Y - GameScene::Scene->BeltDialog->getSize()->Height);
                GameScene::Scene->BeltDialog->setLocation(&tempVar4);
            }
        };

        SettingsButton = new MirButton();
        SettingsButton->setIndex(2060);
        SettingsButton->setHoverIndex(2061);
        SettingsButton->setPressedIndex(2062);
        SettingsButton->setLibrary(Libraries::Prguse);
        SettingsButton->setParent(this);
        Point tempVar5(Settings::Resolution != 800 ? 596 : 372, 1);
        SettingsButton->setLocation(&tempVar5);
        SettingsButton->setSound(SoundList::ButtonA);
        SettingsButton->setHint(GameLanguage::ChatSettings);
        SettingsButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->ChatOptionDialog->getVisible())
            {
                GameScene::Scene->ChatOptionDialog->Hide();
            }
            else
            {
                GameScene::Scene->ChatOptionDialog->Show();
            }
    
            //GameScene.Scene.ChatDialog.Transparent = !GameScene.Scene.ChatDialog.Transparent;
            //GameScene.Scene.ChatDialog.UpdateBackground();
        };

        NormalButton = new MirButton();
        NormalButton->setIndex(2036);
        NormalButton->setHoverIndex(2037);
        NormalButton->setPressedIndex(2038);
        NormalButton->setLibrary(Libraries::Prguse);
        NormalButton->setParent(this);
        Point tempVar6(12, 1);
        NormalButton->setLocation(&tempVar6);
        NormalButton->setSound(SoundList::ButtonA);
        NormalButton->setHint(GameLanguage::Chat_All);
        NormalButton->Click += [&] (o, e)
        {
            ToggleChatFilter("All");
        };

        ShoutButton = new MirButton();
        ShoutButton->setIndex(2039);
        ShoutButton->setHoverIndex(2040);
        ShoutButton->setPressedIndex(2041);
        ShoutButton->setLibrary(Libraries::Prguse);
        ShoutButton->setParent(this);
        Point tempVar7(34, 1);
        ShoutButton->setLocation(&tempVar7);
        ShoutButton->setSound(SoundList::ButtonA);
        ShoutButton->setHint(GameLanguage::Chat_Short);
        ShoutButton->Click += [&] (o, e)
        {
            ToggleChatFilter("Shout");
        };

        WhisperButton = new MirButton();
        WhisperButton->setIndex(2042);
        WhisperButton->setHoverIndex(2043);
        WhisperButton->setPressedIndex(2044);
        WhisperButton->setLibrary(Libraries::Prguse);
        WhisperButton->setParent(this);
        Point tempVar8(56, 1);
        WhisperButton->setLocation(&tempVar8);
        WhisperButton->setSound(SoundList::ButtonA);
        WhisperButton->setHint(GameLanguage::Chat_Whisper);
        WhisperButton->Click += [&] (o, e)
        {
            ToggleChatFilter("Whisper");
        };

        LoverButton = new MirButton();
        LoverButton->setIndex(2045);
        LoverButton->setHoverIndex(2046);
        LoverButton->setPressedIndex(2047);
        LoverButton->setLibrary(Libraries::Prguse);
        LoverButton->setParent(this);
        Point tempVar9(78, 1);
        LoverButton->setLocation(&tempVar9);
        LoverButton->setSound(SoundList::ButtonA);
        LoverButton->setHint(GameLanguage::Chat_Lover);
        LoverButton->Click += [&] (o, e)
        {
            ToggleChatFilter("Lover");
        };

        MentorButton = new MirButton();
        MentorButton->setIndex(2048);
        MentorButton->setHoverIndex(2049);
        MentorButton->setPressedIndex(2050);
        MentorButton->setLibrary(Libraries::Prguse);
        MentorButton->setParent(this);
        Point tempVar10(100, 1);
        MentorButton->setLocation(&tempVar10);
        MentorButton->setSound(SoundList::ButtonA);
        MentorButton->setHint(GameLanguage::Chat_Mentor);
        MentorButton->Click += [&] (o, e)
        {
            ToggleChatFilter("Mentor");
        };

        GroupButton = new MirButton();
        GroupButton->setIndex(2051);
        GroupButton->setHoverIndex(2052);
        GroupButton->setPressedIndex(2053);
        GroupButton->setLibrary(Libraries::Prguse);
        GroupButton->setParent(this);
        Point tempVar11(122, 1);
        GroupButton->setLocation(&tempVar11);
        GroupButton->setSound(SoundList::ButtonA);
        GroupButton->setHint(GameLanguage::Chat_Group);
        GroupButton->Click += [&] (o, e)
        {
            ToggleChatFilter("Group");
        };

        GuildButton = new MirButton();
        GuildButton->setIndex(2054);
        GuildButton->setHoverIndex(2055);
        GuildButton->setPressedIndex(2056);
        GuildButton->setLibrary(Libraries::Prguse);
        GuildButton->setParent(this);
        Point tempVar12(144, 1);
        GuildButton->setLocation(&tempVar12);
        GuildButton->setSound(SoundList::ButtonA);
        GuildButton->setHint(GameLanguage::Chat_Guild);
        GuildButton->Click += [&] (o, e)
        {
            Settings::ShowGuildChat = !Settings::ShowGuildChat;
            ToggleChatFilter("Guild");
        };

        TradeButton = new MirButton();
        TradeButton->setIndex(2004);
        TradeButton->setHoverIndex(2005);
        TradeButton->setPressedIndex(2006);
        TradeButton->setLibrary(Libraries::Prguse);
        Point tempVar13(166, 1);
        TradeButton->setLocation(&tempVar13);
        TradeButton->setParent(this);
        TradeButton->setSound(SoundList::ButtonC);
        TradeButton->setHint(std::string::Format(GameLanguage::Trade, CMain::InputKeys->GetKey(KeybindOptions::Trade)));
        TradeButton->Click += [&] (o, e)
        {
            C::TradeRequest tempVar14();
            Network::Enqueue(&tempVar14);
        };

        ReportButton = new MirButton();
        ReportButton->setIndex(2063);
        ReportButton->setHoverIndex(2064);
        ReportButton->setPressedIndex(2065);
        ReportButton->setLibrary(Libraries::Prguse);
        ReportButton->setParent(this);
        Point tempVar15(Settings::Resolution != 800 ? 552 : 328, 1);
        ReportButton->setLocation(&tempVar15);
        ReportButton->setSound(SoundList::ButtonA);
        ReportButton->setHint("Report");
        ReportButton->setVisible(false);
        ReportButton->Click += [&] (o, e)
        {
            GameScene::Scene->ReportDialog->setVisible(!GameScene::Scene->ReportDialog->getVisible());
        };

        ToggleChatFilter("All");
    }

    void ChatControlBar::ToggleChatFilter(const std::string &chatFilter)
    {
        NormalButton->setIndex(2036);
        NormalButton->setHoverIndex(2037);
        ShoutButton->setIndex(2039);
        ShoutButton->setHoverIndex(2040);
        WhisperButton->setIndex(2042);
        WhisperButton->setHoverIndex(2043);
        LoverButton->setIndex(2045);
        LoverButton->setHoverIndex(2046);
        MentorButton->setIndex(2048);
        MentorButton->setHoverIndex(2049);
        GroupButton->setIndex(2051);
        GroupButton->setHoverIndex(2052);
        GuildButton->setIndex(2054);
        GuildButton->setHoverIndex(2055);

        GameScene::Scene->ChatDialog->ChatPrefix = "";

//C# TO C++ CONVERTER NOTE: The following 'switch' operated on a string and was converted to C++ 'if-else' logic:
//        switch (chatFilter)
//ORIGINAL LINE: case "All":
        if (chatFilter == "All")
        {
                NormalButton->setIndex(2038);
                NormalButton->setHoverIndex(2038);
                GameScene::Scene->ChatDialog->ChatPrefix = "";
        }
//ORIGINAL LINE: case "Shout":
        else if (chatFilter == "Shout")
        {
                ShoutButton->setIndex(2041);
                ShoutButton->setHoverIndex(2041);
                GameScene::Scene->ChatDialog->ChatPrefix = "!";
        }
//ORIGINAL LINE: case "Whisper":
        else if (chatFilter == "Whisper")
        {
                WhisperButton->setIndex(2044);
                WhisperButton->setHoverIndex(2044);
                GameScene::Scene->ChatDialog->ChatPrefix = "/";
        }
//ORIGINAL LINE: case "Group":
        else if (chatFilter == "Group")
        {
                GroupButton->setIndex(2053);
                GroupButton->setHoverIndex(2053);
                GameScene::Scene->ChatDialog->ChatPrefix = "!!";
        }
//ORIGINAL LINE: case "Guild":
        else if (chatFilter == "Guild")
        {
                GuildButton->setIndex(2056);
                GuildButton->setHoverIndex(2056);
                GameScene::Scene->ChatDialog->ChatPrefix = "!~";
        }
//ORIGINAL LINE: case "Lover":
        else if (chatFilter == "Lover")
        {
                LoverButton->setIndex(2047);
                LoverButton->setHoverIndex(2047);
                GameScene::Scene->ChatDialog->ChatPrefix = ":)";
        }
//ORIGINAL LINE: case "Mentor":
        else if (chatFilter == "Mentor")
        {
                MentorButton->setIndex(2050);
                MentorButton->setHoverIndex(2050);
                GameScene::Scene->ChatDialog->ChatPrefix = "!#";
        }
    }

    InventoryDialog::InventoryDialog()
    {
        setIndex(196);
        setLibrary(Libraries::Title);
        setMovable(true);
        setSort(true);
        setVisible(false);

        WeightBar = new MirImageControl();
        WeightBar->setIndex(24);
        WeightBar->setLibrary(Libraries::Prguse);
        Point tempVar(182, 217);
        WeightBar->setLocation(&tempVar);
        WeightBar->setParent(this);
        WeightBar->setDrawImage(false);
        WeightBar->setNotControl(true);

        ItemButton = new MirButton();
        ItemButton->setIndex(197);
        ItemButton->setLibrary(Libraries::Title);
        Point tempVar2(6, 7);
        ItemButton->setLocation(&tempVar2);
        ItemButton->setParent(this);
        Size tempVar3(72, 23);
        ItemButton->setSize(&tempVar3);
        ItemButton->setSound(SoundList::ButtonA);
        ItemButton->Click += Button_Click;

        ItemButton2 = new MirButton();
        ItemButton2->setIndex(738);
        ItemButton2->setLibrary(Libraries::Title);
        Point tempVar4(76, 7);
        ItemButton2->setLocation(&tempVar4);
        ItemButton2->setParent(this);
        Size tempVar5(72, 23);
        ItemButton2->setSize(&tempVar5);
        ItemButton2->setSound(SoundList::ButtonA);
        ItemButton2->Click += Button_Click;

        QuestButton = new MirButton();
        QuestButton->setIndex(739);
        QuestButton->setLibrary(Libraries::Title);
        Point tempVar6(146, 7);
        QuestButton->setLocation(&tempVar6);
        QuestButton->setParent(this);
        Size tempVar7(72, 23);
        QuestButton->setSize(&tempVar7);
        QuestButton->setSound(SoundList::ButtonA);
        QuestButton->Click += Button_Click;

        AddButton = new MirButton();
        AddButton->setIndex(483);
        AddButton->setHoverIndex(484);
        AddButton->setPressedIndex(485);
        AddButton->setLibrary(Libraries::Title);
        Point tempVar8(235, 5);
        AddButton->setLocation(&tempVar8);
        AddButton->setParent(this);
        Size tempVar9(72, 23);
        AddButton->setSize(&tempVar9);
        AddButton->setSound(SoundList::ButtonA);
        AddButton->setVisible(false);
        AddButton->Click += [&] (o1, e)
        {
            int openLevel = (GameScene::getUser()->Inventory.size() - 46) / 4;
            int openGold = (1000000 + openLevel * 1000000);
            MirMessageBox *messageBox = new MirMessageBox(std::string::Format(GameLanguage::ExtraSlots4, openGold), MirMessageBoxButtons::OKCancel);
    
            messageBox->OKButton->Click += [&] (o, a)
            {
                    C::Chat *tempVar10 = new C::Chat();
                    tempVar10->Message = "@ADDINVENTORY";
                    Network::Enqueue(tempVar10);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
            };
            messageBox->Show();

            delete messageBox;
        };

        CloseButton = new MirButton();
        CloseButton->setHoverIndex(361);
        CloseButton->setIndex(360);
        Point tempVar11(289, 3);
        CloseButton->setLocation(&tempVar11);
        CloseButton->setLibrary(Libraries::Prguse2);
        CloseButton->setParent(this);
        CloseButton->setPressedIndex(362);
        CloseButton->setSound(SoundList::ButtonA);
        CloseButton->Click += [&] (o, e)
        {
            Hide();
        };

        GoldLabel = new MirLabel();
        GoldLabel->setParent(this);
        Point tempVar12(40, 212);
        GoldLabel->setLocation(&tempVar12);
        Size tempVar13(111, 14);
        GoldLabel->setSize(&tempVar13);
        GoldLabel->setSound(SoundList::Gold);
        GoldLabel->Click += [&] (o, e)
        {
            if (GameScene::SelectedCell == nullptr)
            {
                GameScene::PickedUpGold = !GameScene::PickedUpGold && GameScene::Gold > 0;
            }
        };


        Grid = std::vector<MirItemCell*>(8 * 10);

        for (int x = 0; x < 8; x++)
        {
            for (int y = 0; y < 10; y++)
            {
                int idx = 8 * y + x;
                MirItemCell *tempVar14 = new MirItemCell();
                tempVar14->setItemSlot(6 + idx);
                tempVar14->setGridType(MirGridType::Inventory);
                tempVar14->setLibrary(Libraries::Items);
                tempVar14->setParent(this);
                Point tempVar15(x * 36 + 9 + x, y % 5 * 32 + 37 + y % 5);
                tempVar14->setLocation(&tempVar15);
                Grid[idx] = tempVar14;

                if (idx >= 40)
                {
                    Grid[idx]->setVisible(false);
                }

                delete tempVar14;
            }
        }

        QuestGrid = std::vector<MirItemCell*>(8 * 5);

        for (int x = 0; x < 8; x++)
        {
            for (int y = 0; y < 5; y++)
            {
                MirItemCell *tempVar16 = new MirItemCell();
                tempVar16->setItemSlot(8 * y + x);
                tempVar16->setGridType(MirGridType::QuestInventory);
                tempVar16->setLibrary(Libraries::Items);
                tempVar16->setParent(this);
                Point tempVar17(x * 36 + 9 + x, y * 32 + 37 + y);
                tempVar16->setLocation(&tempVar17);
                tempVar16->setVisible(false);
                QuestGrid[8 * y + x] = tempVar16;

                delete tempVar16;
            }
        }

        WeightLabel = new MirLabel();
        WeightLabel->setParent(this);
        Point tempVar18(268, 212);
        WeightLabel->setLocation(&tempVar18);
        Size tempVar19(26, 14);
        WeightLabel->setSize(&tempVar19);
        WeightBar->BeforeDraw += WeightBar_BeforeDraw;

        for (int i = 0; i < LockBar.size(); i++)
        {
            MirImageControl *tempVar20 = new MirImageControl();
            tempVar20->setIndex(307);
            tempVar20->setLibrary(Libraries::Prguse2);
            Point tempVar21(9 + i % 2 * 148, 37 + i / 2 * 33);
            tempVar20->setLocation(&tempVar21);
            tempVar20->setParent(this);
            tempVar20->setDrawImage(true);
            tempVar20->setNotControl(true);
            tempVar20->setVisible(false);
            LockBar[i] = tempVar20;

            delete tempVar20;
        }

    }

    void InventoryDialog::Button_Click(std::any sender, EventArgs *e)
    {
        if (GameScene::getUser()->Inventory.size() == 46 && obj::type() == typeid(Client::MirControls::MirButton) && std::any_cast<Client::MirControls::MirButton>(obj) == ItemButton2)
        {
            MirMessageBox *messageBox = new MirMessageBox(GameLanguage::ExtraSlots8, MirMessageBoxButtons::OKCancel);

            messageBox->OKButton->Click += [&] (o, a)
            {
                C::Chat *tempVar = new C::Chat();
                tempVar->Message = "@ADDINVENTORY";
                Network::Enqueue(tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            };
            messageBox->Show();

            delete messageBox;
        }
        else
        {
            if (obj::type() == typeid(Client::MirControls::MirButton) && std::any_cast<Client::MirControls::MirButton>(obj) == ItemButton)
            {
                RefreshInventory();
            }
            else if (obj::type() == typeid(Client::MirControls::MirButton) && std::any_cast<Client::MirControls::MirButton>(obj) == ItemButton2)
            {
                RefreshInventory2();
            }
            else if (obj::type() == typeid(Client::MirControls::MirButton) && std::any_cast<Client::MirControls::MirButton>(obj) == QuestButton)
            {
                Reset();

                ItemButton->setIndex(737);
                ItemButton2->setIndex(738);
                QuestButton->setIndex(198);

                if (GameScene::getUser()->Inventory.size() == 46)
                {
                    ItemButton2->setIndex(169);
                }

                for (auto grid : QuestGrid)
                {
                    grid->setVisible(true);
                }
            }
        }
    }

    void InventoryDialog::Reset()
    {
        for (auto grid : QuestGrid)
        {
            grid->setVisible(false);
        }

        for (auto grid : Grid)
        {
            grid->setVisible(false);
        }

        for (int i = 0; i < LockBar.size(); i++)
        {
            LockBar[i]->setVisible(false);
        }

        AddButton->setVisible(false);
    }

    void InventoryDialog::RefreshInventory()
    {
        Reset();

        ItemButton->setIndex(197);
        ItemButton2->setIndex(738);
        QuestButton->setIndex(739);

        if (GameScene::getUser()->Inventory.size() == 46)
        {
            ItemButton2->setIndex(169);
        }

        for (auto grid : Grid)
        {
            if (grid->getItemSlot() < 46)
            {
                grid->setVisible(true);
            }
            else
            {
                grid->setVisible(false);
            }
        }
    }

    void InventoryDialog::RefreshInventory2()
    {
        Reset();

        ItemButton->setIndex(737);
        ItemButton2->setIndex(168);
        QuestButton->setIndex(739);

        for (auto grid : Grid)
        {
            if (grid->getItemSlot() < 46 || grid->getItemSlot() >= GameScene::getUser()->Inventory.size())
            {
                grid->setVisible(false);
            }
            else
            {
                grid->setVisible(true);
            }
        }

        int openLevel = (GameScene::getUser()->Inventory.size() - 46) / 4;
        for (int i = 0; i < LockBar.size(); i++)
        {
            LockBar[i]->setVisible((i < openLevel) ? false : true);
        }

        AddButton->setVisible(openLevel >= 10 ? false : true);
    }

    void InventoryDialog::Process()
    {
        WeightLabel->setText(std::to_string(GameScene::getUser()->Inventory.Count([&] (std::any t)
        {
            return t == nullptr;
        })));
        //WeightLabel.Text = (MapObject.User.MaxBagWeight - MapObject.User.CurrentBagWeight).ToString();
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
        GoldLabel->setText(GameScene::Gold.ToString("###,###,##0"));
    }

    void InventoryDialog::WeightBar_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (WeightBar->getLibrary() == nullptr)
        {
            return;
        }

        double percent = MapObject::User->CurrentBagWeight / static_cast<double>(MapObject::User->Stats[Stat::BagWeight]);
        if (percent > 1)
        {
            percent = 1;
        }
        if (percent <= 0)
        {
            return;
        }

        Rectangle *section = new Rectangle();
        section->Size = new Size(static_cast<int>((WeightBar->getSize()->Width - 3) * percent), WeightBar->getSize()->Height);

        WeightBar->getLibrary()->Draw(WeightBar->getIndex(), section, WeightBar->getDisplayLocation(), Color::White, false);

//C# TO C++ CONVERTER TODO TASK: A 'delete section' statement was not added since section was passed to a method or constructor. Handle memory management manually.
    }

    MirItemCell *InventoryDialog::GetCell(unsigned long long id)
    {
        for (int i = 0; i < Grid.size(); i++)
        {
            if (Grid[i]->getItem() == nullptr || Grid[i]->getItem().UniqueID != id)
            {
                continue;
            }
            return Grid[i];
        }
        return nullptr;
    }

    MirItemCell *InventoryDialog::GetQuestCell(unsigned long long id)
    {
        return QuestGrid.FirstOrDefault([&] (std::any t)
        {
            return t::Item != nullptr && t::Item->UniqueID == id;
        });
    }

    void InventoryDialog::DisplayItemGridEffect(unsigned long long id, int type)
    {
        MirItemCell *cell = GetCell(id);

        if (cell->getItem() == nullptr)
        {
            return;
        }

        MirAnimatedControl *animEffect = nullptr;

        switch (type)
        {
            case 0:
                animEffect = new MirAnimatedControl();
                animEffect->setAnimated(true);
                animEffect->setAnimationCount(9);
                animEffect->setAnimationDelay(150);
                animEffect->setIndex(410);
                animEffect->setLibrary(Libraries::Prguse);
                animEffect->setLocation(cell->getLocation());
                animEffect->setParent(this);
                animEffect->setLoop(false);
                animEffect->setNotControl(true);
                animEffect->setUseOffSet(true);
                animEffect->setBlending(true);
                animEffect->setBlendingRate(1.0F);
                animEffect->AfterAnimation->addListener([&] (o, e)
                {
                    animEffect->Dispose();
                });
                SoundManager::PlaySound(20000 + static_cast<unsigned short>(Spell::MagicShield) * 10);
                break;
        }

        delete animEffect;
    }

    BeltDialog::BeltDialog()
    {
        setIndex(1932);
        setLibrary(Libraries::Prguse);
        setMovable(true);
        setSort(true);
        setVisible(true);
        Point tempVar(GameScene::Scene->MainDialog->getLocation()->X + 230, Settings::ScreenHeight - 150);
        setLocation(&tempVar);

        BeforeDraw += BeltPanel_BeforeDraw;

        for (int i = 0; i < Key.size(); i++)
        {
            MirLabel *tempVar2 = new MirLabel();
            tempVar2->setParent(this);
            Size tempVar3(26, 14);
            tempVar2->setSize(&tempVar3);
            Point tempVar4(8 + i * 35, 2);
            tempVar2->setLocation(&tempVar4);
            tempVar2->setText(std::to_string(i + 1));
            Key[i] = tempVar2;

            delete tempVar2;
        }

        RotateButton = new MirButton();
        RotateButton->setHoverIndex(1927);
        RotateButton->setIndex(1926);
        Point tempVar5(222, 3);
        RotateButton->setLocation(&tempVar5);
        RotateButton->setLibrary(Libraries::Prguse);
        RotateButton->setParent(this);
        RotateButton->setPressedIndex(1928);
        RotateButton->setSound(SoundList::ButtonA);
        RotateButton->setHint(GameLanguage::Rotate);
        RotateButton->Click += [&] (o, e)
        {
            Flip();
        };

        CloseButton = new MirButton();
        CloseButton->setHoverIndex(1924);
        CloseButton->setIndex(1923);
        Point tempVar6(222, 19);
        CloseButton->setLocation(&tempVar6);
        CloseButton->setLibrary(Libraries::Prguse);
        CloseButton->setParent(this);
        CloseButton->setPressedIndex(1925);
        CloseButton->setSound(SoundList::ButtonA);
        CloseButton->setHint(std::string::Format(GameLanguage::Close, CMain::InputKeys->GetKey(KeybindOptions::Belt)));
        CloseButton->Click += [&] (o, e)
        {
            Hide();
        };

        Grid = std::vector<MirItemCell*>(6);

        for (int x = 0; x < 6; x++)
        {
            MirItemCell *tempVar7 = new MirItemCell();
            tempVar7->setItemSlot(x);
            Size tempVar8(32, 32);
            tempVar7->setSize(&tempVar8);
            tempVar7->setGridType(MirGridType::Inventory);
            tempVar7->setLibrary(Libraries::Items);
            tempVar7->setParent(this);
            Point tempVar9(x * 35 + 12, 3);
            tempVar7->setLocation(&tempVar9);
            Grid[x] = tempVar7;

            delete tempVar7;
        }

    }

    void BeltDialog::BeltPanel_BeforeDraw(std::any sender, EventArgs *e)
    {
        //if Transparent return

        if (Libraries::Prguse != nullptr)
        {
            Libraries::Prguse->Draw(getIndex() + 1, getDisplayLocation(), Color::White, false, 0.5F);
        }
    }

    void BeltDialog::Flip()
    {
        //0,70 LOCATION
        if (getIndex() == 1932)
        {
            setIndex(1944);
            Point tempVar(0, 200);
            setLocation(&tempVar);

            for (int x = 0; x < 6; x++)
            {
                Point tempVar2(3, x * 35 + 12);
                Grid[x]->setLocation(&tempVar2);
            }

            CloseButton->setIndex(1935);
            CloseButton->setHoverIndex(1936);
            Point tempVar3(3, 222);
            CloseButton->setLocation(&tempVar3);
            CloseButton->setPressedIndex(1937);

            RotateButton->setIndex(1938);
            RotateButton->setHoverIndex(1939);
            Point tempVar4(19, 222);
            RotateButton->setLocation(&tempVar4);
            RotateButton->setPressedIndex(1940);

        }
        else
        {
            setIndex(1932);
            Point tempVar5(GameScene::Scene->MainDialog->getLocation()->X + 230, Settings::ScreenHeight - 150);
            setLocation(&tempVar5);

            for (int x = 0; x < 6; x++)
            {
                Point tempVar6(x * 35 + 12, 3);
                Grid[x]->setLocation(&tempVar6);
            }

            CloseButton->setIndex(1923);
            CloseButton->setHoverIndex(1924);
            Point tempVar7(222, 19);
            CloseButton->setLocation(&tempVar7);
            CloseButton->setPressedIndex(1925);

            RotateButton->setIndex(1926);
            RotateButton->setHoverIndex(1927);
            Point tempVar8(222, 3);
            RotateButton->setLocation(&tempVar8);
            RotateButton->setPressedIndex(1928);
        }

        for (int i = 0; i < Key.size(); i++)
        {
            Point tempVar9(8 + i * 35, 2);
            Key[i]->setLocation((getIndex() != 1932) ? new Point(-1, 11 + i * 35) : &tempVar9);
        }
    }

    MirItemCell *BeltDialog::GetCell(unsigned long long id)
    {
        for (int i = 0; i < Grid.size(); i++)
        {
            if (Grid[i]->getItem() == nullptr || Grid[i]->getItem().UniqueID != id)
            {
                continue;
            }
            return Grid[i];
        }
        return nullptr;
    }

    SkillBarDialog::SkillBarDialog() : _switchBindsButton(new MirButton();
        _switchBindsButton->setIndex(2247);
        _switchBindsButton->setLibrary(Libraries::Prguse);
        _switchBindsButton->setParent(this);
        _switchBindsButton->setSound(SoundList::ButtonA);
        Size tempVar(16, 28);
        _switchBindsButton->setSize(&tempVar);
        Point tempVar2(0, 0);
        _switchBindsButton->setLocation(&tempVar2))
        {
        setIndex(2190);
        setLibrary(Libraries::Prguse);
        setMovable(true);
        setSort(true);
        Point tempVar3(0, BarIndex * 20);
        setLocation(&tempVar3);
        setVisible(true);

        BeforeDraw += MagicKeyDialog_BeforeDraw;

        _switchBindsButton->Click += [&] (o, e)
        {
            //Settings.SkillSet = !Settings.SkillSet;
    
            Update();
        };

        for (auto i = 0; i < Cells.size(); i++)
        {
            MirImageControl *tempVar4 = new MirImageControl();
            tempVar4->setIndex(-1);
            tempVar4->setLibrary(Libraries::MagIcon);
            tempVar4->setParent(this);
            Point tempVar5(i * 25 + 15, 3);
            tempVar4->setLocation(&tempVar5);
            Cells[i] = tempVar4;
            int j = i + 1;
            Cells[i]->Click += [&] (o, e)
            {
                    GameScene::Scene->UseSpell(j + (8 * BarIndex));
            };

            MirAnimatedControl *tempVar6 = new MirAnimatedControl();
            tempVar6->setLibrary(Libraries::Prguse2);
            tempVar6->setParent(this);
            Point tempVar7(i * 25 + 15, 3);
            tempVar6->setLocation(&tempVar7);
            tempVar6->setNotControl(true);
            tempVar6->setUseOffSet(true);
            tempVar6->setLoop(false);
            tempVar6->setAnimated(false);
            tempVar6->setOpacity(0.6F);
            CoolDowns[i] = tempVar6;

            delete tempVar6;
            delete tempVar4;
        }

        BindNumberLabel = new MirLabel();
        BindNumberLabel->setText("1");
        System::Drawing::Font tempVar8(Settings::FontName, 8.0F);
        BindNumberLabel->setFont(&tempVar8);
        BindNumberLabel->setForeColour(Color::White);
        BindNumberLabel->setParent(this);
        Point tempVar9(0, 1);
        BindNumberLabel->setLocation(&tempVar9);
        Size tempVar10(10, 25);
        BindNumberLabel->setSize(&tempVar10);
        BindNumberLabel->setNotControl(true);

        for (auto i = 0; i < KeyNameLabels.size(); i++)
        {
            MirLabel *tempVar11 = new MirLabel();
            tempVar11->setText("F" + std::to_string(i + 1));
            System::Drawing::Font tempVar12(Settings::FontName, 8.0F);
            tempVar11->setFont(&tempVar12);
            tempVar11->setForeColour(Color::White);
            tempVar11->setParent(this);
            Point tempVar13(i * 25 + 13, 0);
            tempVar11->setLocation(&tempVar13);
            Size tempVar14(25, 25);
            tempVar11->setSize(&tempVar14);
            tempVar11->setNotControl(true);
            KeyNameLabels[i] = tempVar11;

            delete tempVar11;
        }
        OnMoving += SkillBar_OnMoving;
        }

    void SkillBarDialog::SkillBar_OnMoving(std::any sender, MouseEventArgs *e)
    {
        if (BarIndex * 2 >= Settings::SkillbarLocation.size())
        {
            return;
        }
        Settings::SkillbarLocation[BarIndex][0] = this->getLocation()->X;
        Settings::SkillbarLocation[BarIndex][1] = this->getLocation()->Y;
    }

    std::string SkillBarDialog::GetKey(int barindex, int i)
    {
        //KeybindOptions Type = KeybindOptions.Bar1Skill1;
        if ((barindex == 0) && (i == 1))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill1);
        }
        if ((barindex == 0) && (i == 2))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill2);
        }
        if ((barindex == 0) && (i == 3))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill3);
        }
        if ((barindex == 0) && (i == 4))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill4);
        }
        if ((barindex == 0) && (i == 5))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill5);
        }
        if ((barindex == 0) && (i == 6))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill6);
        }
        if ((barindex == 0) && (i == 7))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill7);
        }
        if ((barindex == 0) && (i == 8))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar1Skill8);
        }
        if ((barindex == 1) && (i == 1))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill1);
        }
        if ((barindex == 1) && (i == 2))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill2);
        }
        if ((barindex == 1) && (i == 3))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill3);
        }
        if ((barindex == 1) && (i == 4))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill4);
        }
        if ((barindex == 1) && (i == 5))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill5);
        }
        if ((barindex == 1) && (i == 6))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill6);
        }
        if ((barindex == 1) && (i == 7))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill7);
        }
        if ((barindex == 1) && (i == 8))
        {
            return CMain::InputKeys->GetKey(KeybindOptions::Bar2Skill8);
        }
        return "";
    }

    void SkillBarDialog::MagicKeyDialog_BeforeDraw(std::any sender, EventArgs *e)
    {
        Point tempVar(getDisplayLocation()->X + 12, getDisplayLocation()->Y);
        Libraries::Prguse->Draw(2193, &tempVar, Color::White, true, 0.5F);
    }

    void SkillBarDialog::Update()
    {
        HasSkill = false;
        for (auto m : GameScene::getUser()->Magics)
        {
            if ((m->Key < (BarIndex * 8) + 1) || (m->Key > ((BarIndex + 1) * 8) + 1))
            {
                continue;
            }
            HasSkill = true;
        }
        if (!getVisible())
        {
            return;
        }
        setIndex(2190);
        _switchBindsButton->setIndex(2247);
        BindNumberLabel->setText(std::to_string(BarIndex + 1));
        Point tempVar(0, 1);
        BindNumberLabel->setLocation(&tempVar);

        for (auto i = 1; i <= 8; i++)
        {
            Cells[i - 1]->setIndex(-1);

            int offset = BarIndex * 8;
            std::string key = GetKey(BarIndex, i);
            KeyNameLabels[i - 1]->setText(key);

            for (auto m : GameScene::getUser()->Magics)
            {
                if (m->Key != i + offset)
                {
                    continue;
                }
                HasSkill = true;
                ClientMagic *magic = MapObject::User->GetMagic(m->Spell);
                if (magic == nullptr)
                {
                    continue;
                }

                //string key = m.Key > 8 ? string.Format("CTRL F{0}", i) : string.Format("F{0}", m.Key);

                Cells[i - 1]->setIndex(magic->Icon * 2);
                Cells[i - 1]->setHint(std::string::Format("{0}\nMP: {1}\nCooldown: {2}\nKey: {3}", magic->Name, (magic->BaseCost + (magic->LevelCost * magic->Level)), Functions::PrintTimeSpanFromMilliSeconds(magic->Delay), key));

                KeyNameLabels[i - 1]->setText("");
            }

            CoolDowns[i - 1]->Dispose();
        }
    }

    void SkillBarDialog::Process()
    {
        ProcessSkillDelay();
    }

    void SkillBarDialog::ProcessSkillDelay()
    {
        if (!getVisible())
        {
            return;
        }

        int offset = BarIndex * 8;

        for (int i = 0; i < Cells.size(); i++)
        {
            for (auto magic : GameScene::getUser()->Magics)
            {
                if (magic->Key != i + offset + 1)
                {
                    continue;
                }

                int totalFrames = 22;
                long long timeLeft = magic->CastTime + magic->Delay - CMain::Time;

                if (timeLeft < 100 || (CoolDowns[i] != nullptr && CoolDowns[i]->getAnimated()))
                {
                    if (timeLeft > 0)
                    {
                        CoolDowns[i]->Dispose();
                    }
                    else
                    {
                        continue;
                    }
                }

                int delayPerFrame = static_cast<int>(magic->Delay / totalFrames);
                int startFrame = totalFrames - static_cast<int>(timeLeft / delayPerFrame);

                if ((CMain::Time <= magic->CastTime + magic->Delay) && magic->CastTime > 0)
                {
                    CoolDowns[i]->Dispose();

                    MirAnimatedControl *tempVar = new MirAnimatedControl();
                    tempVar->setIndex(1260 + startFrame);
                    tempVar->setAnimationCount((totalFrames - startFrame));
                    tempVar->setAnimationDelay(delayPerFrame);
                    tempVar->setLibrary(Libraries::Prguse2);
                    tempVar->setParent(this);
                    Point tempVar2(i * 25 + 15, 3);
                    tempVar->setLocation(&tempVar2);
                    tempVar->setNotControl(true);
                    tempVar->setUseOffSet(true);
                    tempVar->setLoop(false);
                    tempVar->setAnimated(true);
                    tempVar->setOpacity(0.6F);
                    CoolDowns[i] = tempVar;

                    delete tempVar;
                }
            }
        }
    }

    void SkillBarDialog::Show()
    {
        if (getVisible())
        {
            return;
        }
        if (!HasSkill)
        {
            return;
        }
        Settings::SkillBar = true;
        setVisible(true);
        Update();
    }

    void SkillBarDialog::Hide()
    {
        if (!getVisible())
        {
            return;
        }
        Settings::SkillBar = false;
        setVisible(false);
    }

    CharacterDialog::CharacterDialog()
    {
        setIndex(504);
        setLibrary(Libraries::Title);
        Point tempVar(Settings::ScreenWidth - 264, 0);
        setLocation(&tempVar);
        setMovable(true);
        setSort(true);

        BeforeDraw += [&] (o, e)
        {
            RefreshInterface();
        };

        CharacterPage = new MirImageControl();
        CharacterPage->setIndex(340);
        CharacterPage->setParent(this);
        CharacterPage->setLibrary(Libraries::Prguse);
        Point tempVar2(8, 90);
        CharacterPage->setLocation(&tempVar2);
        CharacterPage->AfterDraw += [&] (o, e)
        {
            if (Libraries::StateItems == nullptr)
            {
                return;
            }
            ItemInfo *RealItem = nullptr;
            if (Grid[static_cast<int>(EquipmentSlot::Armour)]->getItem() != nullptr)
            {
                if (GameScene::getUser()->WingEffect == 1 || GameScene::getUser()->WingEffect == 2)
                {
                    int wingOffset = GameScene::getUser()->WingEffect == 1 ? 2 : 4;
    
                    int genderOffset = MapObject::User->Gender == MirGender::Male ? 0 : 1;
    
                    Libraries::Prguse2->DrawBlend(1200 + wingOffset + genderOffset, getDisplayLocation(), Color::White, true, 1.0F);
                }
    
                RealItem = Functions::GetRealItem(Grid[static_cast<int>(EquipmentSlot::Armour)]->getItem().Info, MapObject::User->Level, MapObject::User->Class, GameScene::ItemInfoList);
                Libraries::StateItems->Draw(RealItem->Image, getDisplayLocation(), Color::White, true, 1.0F);
    
            }
            if (Grid[static_cast<int>(EquipmentSlot::Weapon)]->getItem() != nullptr)
            {
                RealItem = Functions::GetRealItem(Grid[static_cast<int>(EquipmentSlot::Weapon)]->getItem().Info, MapObject::User->Level, MapObject::User->Class, GameScene::ItemInfoList);
                Libraries::StateItems->Draw(RealItem->Image, getDisplayLocation(), Color::White, true, 1.0F);
    
            }
    
            if (Grid[static_cast<int>(EquipmentSlot::Helmet)]->getItem() != nullptr)
            {
                Libraries::StateItems->Draw(Grid[static_cast<int>(EquipmentSlot::Helmet)]->getItem().Info.Image, getDisplayLocation(), Color::White, true, 1.0F);
            }
            else
            {
                int hair = 441 + MapObject::User->Hair + (MapObject::User->Class == MirClass::Assassin ? 20 : 0) + (MapObject::User->Gender == MirGender::Male ? 0 : 40);
    
                int offSetX = MapObject::User->Class == MirClass::Assassin ? (MapObject::User->Gender == MirGender::Male ? 6 : 4) : 0;
                int offSetY = MapObject::User->Class == MirClass::Assassin ? (MapObject::User->Gender == MirGender::Male ? 25 : 18) : 0;
    
                Point tempVar3(getDisplayLocation()->X + offSetX, getDisplayLocation()->Y + offSetY);
                Libraries::Prguse->Draw(hair, &tempVar3, Color::White, true, 1.0F);
            }
        };

        StatusPage = new MirImageControl();
        StatusPage->setIndex(506);
        StatusPage->setParent(this);
        StatusPage->setLibrary(Libraries::Title);
        Point tempVar4(8, 90);
        StatusPage->setLocation(&tempVar4);
        StatusPage->setVisible(false);
        StatusPage->BeforeDraw += [&] (o, e)
        {
            ACLabel->setText(StringHelper::formatSimple("{0}-{1}", MapObject::User->Stats[Stat::MinAC], MapObject::User->Stats[Stat::MaxAC]));
            MACLabel->setText(StringHelper::formatSimple("{0}-{1}", MapObject::User->Stats[Stat::MinMAC], MapObject::User->Stats[Stat::MaxMAC]));
            DCLabel->setText(StringHelper::formatSimple("{0}-{1}", MapObject::User->Stats[Stat::MinDC], MapObject::User->Stats[Stat::MaxDC]));
            MCLabel->setText(StringHelper::formatSimple("{0}-{1}", MapObject::User->Stats[Stat::MinMC], MapObject::User->Stats[Stat::MaxMC]));
            SCLabel->setText(StringHelper::formatSimple("{0}-{1}", MapObject::User->Stats[Stat::MinSC], MapObject::User->Stats[Stat::MaxSC]));
            HealthLabel->setText(StringHelper::formatSimple("{0}/{1}", MapObject::User->HP, MapObject::User->Stats[Stat::HP]));
            ManaLabel->setText(StringHelper::formatSimple("{0}/{1}", MapObject::User->MP, MapObject::User->Stats[Stat::MP]));
            CritRLabel->setText(StringHelper::formatSimple("{0}%", MapObject::User->Stats[Stat::CriticalRate]));
            CritDLabel->setText(StringHelper::formatSimple("{0}", MapObject::User->Stats[Stat::CriticalDamage]));
            AttkSpdLabel->setText(StringHelper::formatSimple("{0}", MapObject::User->Stats[Stat::AttackSpeed]));
            AccLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::Accuracy]));
            AgilLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::Agility]));
            LuckLabel->setText(StringHelper::formatSimple("{0}", MapObject::User->Stats[Stat::Luck]));
        };

        StatePage = new MirImageControl();
        StatePage->setIndex(507);
        StatePage->setParent(this);
        StatePage->setLibrary(Libraries::Title);
        Point tempVar5(8, 90);
        StatePage->setLocation(&tempVar5);
        StatePage->setVisible(false);
        StatePage->BeforeDraw += [&] (o, e)
        {
            ExpPLabel->setText(std::string::Format("{0:0.##%}", MapObject::User->Experience / static_cast<double>(MapObject::User->MaxExperience)));
            BagWLabel->setText(StringHelper::formatSimple("{0}/{1}", MapObject::User->CurrentBagWeight, MapObject::User->Stats[Stat::BagWeight]));
            WearWLabel->setText(StringHelper::formatSimple("{0}/{1}", MapObject::User->CurrentWearWeight, MapObject::User->Stats[Stat::WearWeight]));
            HandWLabel->setText(StringHelper::formatSimple("{0}/{1}", MapObject::User->CurrentHandWeight, MapObject::User->Stats[Stat::HandWeight]));
            MagicRLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::MagicResist]));
            PoisonResLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::PoisonResist]));
            HealthRLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::HealthRecovery]));
            ManaRLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::SpellRecovery]));
            PoisonRecLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::PoisonRecovery]));
            HolyTLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::Holy]));
            FreezeLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::Freezing]));
            PoisonAtkLabel->setText(StringHelper::formatSimple("+{0}", MapObject::User->Stats[Stat::PoisonAttack]));
        };


        SkillPage = new MirImageControl();
        SkillPage->setIndex(508);
        SkillPage->setParent(this);
        SkillPage->setLibrary(Libraries::Title);
        Point tempVar6(8, 90);
        SkillPage->setLocation(&tempVar6);
        SkillPage->setVisible(false);


        CharacterButton = new MirButton();
        CharacterButton->setIndex(500);
        CharacterButton->setLibrary(Libraries::Title);
        Point tempVar7(8, 70);
        CharacterButton->setLocation(&tempVar7);
        CharacterButton->setParent(this);
        CharacterButton->setPressedIndex(500);
        Size tempVar8(64, 20);
        CharacterButton->setSize(&tempVar8);
        CharacterButton->setSound(SoundList::ButtonA);
        CharacterButton->Click += [&] (o, e)
        {
            ShowCharacterPage();
        };
        StatusButton = new MirButton();
        StatusButton->setLibrary(Libraries::Title);
        Point tempVar9(70, 70);
        StatusButton->setLocation(&tempVar9);
        StatusButton->setParent(this);
        StatusButton->setPressedIndex(501);
        Size tempVar10(64, 20);
        StatusButton->setSize(&tempVar10);
        StatusButton->setSound(SoundList::ButtonA);
        StatusButton->Click += [&] (o, e)
        {
            ShowStatusPage();
        };

        StateButton = new MirButton();
        StateButton->setLibrary(Libraries::Title);
        Point tempVar11(132, 70);
        StateButton->setLocation(&tempVar11);
        StateButton->setParent(this);
        StateButton->setPressedIndex(502);
        Size tempVar12(64, 20);
        StateButton->setSize(&tempVar12);
        StateButton->setSound(SoundList::ButtonA);
        StateButton->Click += [&] (o, e)
        {
            ShowStatePage();
        };

        SkillButton = new MirButton();
        SkillButton->setLibrary(Libraries::Title);
        Point tempVar13(194, 70);
        SkillButton->setLocation(&tempVar13);
        SkillButton->setParent(this);
        SkillButton->setPressedIndex(503);
        Size tempVar14(64, 20);
        SkillButton->setSize(&tempVar14);
        SkillButton->setSound(SoundList::ButtonA);
        SkillButton->Click += [&] (o, e)
        {
            ShowSkillPage();
        };

        CloseButton = new MirButton();
        CloseButton->setHoverIndex(361);
        CloseButton->setIndex(360);
        Point tempVar15(241, 3);
        CloseButton->setLocation(&tempVar15);
        CloseButton->setLibrary(Libraries::Prguse2);
        CloseButton->setParent(this);
        CloseButton->setPressedIndex(362);
        CloseButton->setSound(SoundList::ButtonA);
        CloseButton->Click += [&] (o, e)
        {
            Hide();
        };

        NameLabel = new MirLabel();
        NameLabel->setDrawFormat(TextFormatFlags::VerticalCenter | TextFormatFlags::HorizontalCenter);
        NameLabel->setParent(this);
        Point tempVar16(0, 12);
        NameLabel->setLocation(&tempVar16);
        Size tempVar17(264, 20);
        NameLabel->setSize(&tempVar17);
        NameLabel->setNotControl(true);
        GuildLabel = new MirLabel();
        GuildLabel->setDrawFormat(TextFormatFlags::VerticalCenter | TextFormatFlags::HorizontalCenter);
        GuildLabel->setParent(this);
        Point tempVar18(0, 33);
        GuildLabel->setLocation(&tempVar18);
        Size tempVar19(264, 30);
        GuildLabel->setSize(&tempVar19);
        GuildLabel->setNotControl(true);
        ClassImage = new MirImageControl();
        ClassImage->setIndex(100);
        ClassImage->setLibrary(Libraries::Prguse);
        Point tempVar20(15, 33);
        ClassImage->setLocation(&tempVar20);
        ClassImage->setParent(this);
        ClassImage->setNotControl(true);

//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the C# 'typeof' operator:
        Grid = std::vector<MirItemCell*>(Enum::GetNames(typeof(EquipmentSlot)).size());

        MirItemCell *tempVar21 = new MirItemCell();
        tempVar21->setItemSlot(static_cast<int>(EquipmentSlot::Weapon));
        tempVar21->setGridType(MirGridType::Equipment);
        tempVar21->setParent(CharacterPage);
        Point tempVar22(123, 7);
        tempVar21->setLocation(&tempVar22);
        Grid[static_cast<int>(EquipmentSlot::Weapon)] = tempVar21;


        MirItemCell *tempVar23 = new MirItemCell();
        tempVar23->setItemSlot(static_cast<int>(EquipmentSlot::Armour));
        tempVar23->setGridType(MirGridType::Equipment);
        tempVar23->setParent(CharacterPage);
        Point tempVar24(163, 7);
        tempVar23->setLocation(&tempVar24);
        Grid[static_cast<int>(EquipmentSlot::Armour)] = tempVar23;


        MirItemCell *tempVar25 = new MirItemCell();
        tempVar25->setItemSlot(static_cast<int>(EquipmentSlot::Helmet));
        tempVar25->setGridType(MirGridType::Equipment);
        tempVar25->setParent(CharacterPage);
        Point tempVar26(203, 7);
        tempVar25->setLocation(&tempVar26);
        Grid[static_cast<int>(EquipmentSlot::Helmet)] = tempVar25;



        MirItemCell *tempVar27 = new MirItemCell();
        tempVar27->setItemSlot(static_cast<int>(EquipmentSlot::Torch));
        tempVar27->setGridType(MirGridType::Equipment);
        tempVar27->setParent(CharacterPage);
        Point tempVar28(203, 134);
        tempVar27->setLocation(&tempVar28);
        Grid[static_cast<int>(EquipmentSlot::Torch)] = tempVar27;


        MirItemCell *tempVar29 = new MirItemCell();
        tempVar29->setItemSlot(static_cast<int>(EquipmentSlot::Necklace));
        tempVar29->setGridType(MirGridType::Equipment);
        tempVar29->setParent(CharacterPage);
        Point tempVar30(203, 98);
        tempVar29->setLocation(&tempVar30);
        Grid[static_cast<int>(EquipmentSlot::Necklace)] = tempVar29;


        MirItemCell *tempVar31 = new MirItemCell();
        tempVar31->setItemSlot(static_cast<int>(EquipmentSlot::BraceletL));
        tempVar31->setGridType(MirGridType::Equipment);
        tempVar31->setParent(CharacterPage);
        Point tempVar32(8, 170);
        tempVar31->setLocation(&tempVar32);
        Grid[static_cast<int>(EquipmentSlot::BraceletL)] = tempVar31;

        MirItemCell *tempVar33 = new MirItemCell();
        tempVar33->setItemSlot(static_cast<int>(EquipmentSlot::BraceletR));
        tempVar33->setGridType(MirGridType::Equipment);
        tempVar33->setParent(CharacterPage);
        Point tempVar34(203, 170);
        tempVar33->setLocation(&tempVar34);
        Grid[static_cast<int>(EquipmentSlot::BraceletR)] = tempVar33;

        MirItemCell *tempVar35 = new MirItemCell();
        tempVar35->setItemSlot(static_cast<int>(EquipmentSlot::RingL));
        tempVar35->setGridType(MirGridType::Equipment);
        tempVar35->setParent(CharacterPage);
        Point tempVar36(8, 206);
        tempVar35->setLocation(&tempVar36);
        Grid[static_cast<int>(EquipmentSlot::RingL)] = tempVar35;

        MirItemCell *tempVar37 = new MirItemCell();
        tempVar37->setItemSlot(static_cast<int>(EquipmentSlot::RingR));
        tempVar37->setGridType(MirGridType::Equipment);
        tempVar37->setParent(CharacterPage);
        Point tempVar38(203, 206);
        tempVar37->setLocation(&tempVar38);
        Grid[static_cast<int>(EquipmentSlot::RingR)] = tempVar37;


        MirItemCell *tempVar39 = new MirItemCell();
        tempVar39->setItemSlot(static_cast<int>(EquipmentSlot::Amulet));
        tempVar39->setGridType(MirGridType::Equipment);
        tempVar39->setParent(CharacterPage);
        Point tempVar40(8, 242);
        tempVar39->setLocation(&tempVar40);
        Grid[static_cast<int>(EquipmentSlot::Amulet)] = tempVar39;


        MirItemCell *tempVar41 = new MirItemCell();
        tempVar41->setItemSlot(static_cast<int>(EquipmentSlot::Boots));
        tempVar41->setGridType(MirGridType::Equipment);
        tempVar41->setParent(CharacterPage);
        Point tempVar42(48, 242);
        tempVar41->setLocation(&tempVar42);
        Grid[static_cast<int>(EquipmentSlot::Boots)] = tempVar41;

        MirItemCell *tempVar43 = new MirItemCell();
        tempVar43->setItemSlot(static_cast<int>(EquipmentSlot::Belt));
        tempVar43->setGridType(MirGridType::Equipment);
        tempVar43->setParent(CharacterPage);
        Point tempVar44(88, 242);
        tempVar43->setLocation(&tempVar44);
        Grid[static_cast<int>(EquipmentSlot::Belt)] = tempVar43;


        MirItemCell *tempVar45 = new MirItemCell();
        tempVar45->setItemSlot(static_cast<int>(EquipmentSlot::Stone));
        tempVar45->setGridType(MirGridType::Equipment);
        tempVar45->setParent(CharacterPage);
        Point tempVar46(128, 242);
        tempVar45->setLocation(&tempVar46);
        Grid[static_cast<int>(EquipmentSlot::Stone)] = tempVar45;

        MirItemCell *tempVar47 = new MirItemCell();
        tempVar47->setItemSlot(static_cast<int>(EquipmentSlot::Mount));
        tempVar47->setGridType(MirGridType::Equipment);
        tempVar47->setParent(CharacterPage);
        Point tempVar48(203, 62);
        tempVar47->setLocation(&tempVar48);
        Grid[static_cast<int>(EquipmentSlot::Mount)] = tempVar47;

        // STATS I
        HealthLabel = new MirLabel();
        HealthLabel->setAutoSize(true);
        HealthLabel->setParent(StatusPage);
        Point tempVar49(126, 20);
        HealthLabel->setLocation(&tempVar49);
        HealthLabel->setNotControl(true);
        HealthLabel->setText("0-0");

        ManaLabel = new MirLabel();
        ManaLabel->setAutoSize(true);
        ManaLabel->setParent(StatusPage);
        Point tempVar50(126, 38);
        ManaLabel->setLocation(&tempVar50);
        ManaLabel->setNotControl(true);
        ManaLabel->setText("0-0");

        ACLabel = new MirLabel();
        ACLabel->setAutoSize(true);
        ACLabel->setParent(StatusPage);
        Point tempVar51(126, 56);
        ACLabel->setLocation(&tempVar51);
        ACLabel->setNotControl(true);
        ACLabel->setText("0-0");

        MACLabel = new MirLabel();
        MACLabel->setAutoSize(true);
        MACLabel->setParent(StatusPage);
        Point tempVar52(126, 74);
        MACLabel->setLocation(&tempVar52);
        MACLabel->setNotControl(true);
        MACLabel->setText("0-0");
        DCLabel = new MirLabel();
        DCLabel->setAutoSize(true);
        DCLabel->setParent(StatusPage);
        Point tempVar53(126, 92);
        DCLabel->setLocation(&tempVar53);
        DCLabel->setNotControl(true);
        DCLabel->setText("0-0");
        MCLabel = new MirLabel();
        MCLabel->setAutoSize(true);
        MCLabel->setParent(StatusPage);
        Point tempVar54(126, 110);
        MCLabel->setLocation(&tempVar54);
        MCLabel->setNotControl(true);
        MCLabel->setText("0/0");
        SCLabel = new MirLabel();
        SCLabel->setAutoSize(true);
        SCLabel->setParent(StatusPage);
        Point tempVar55(126, 128);
        SCLabel->setLocation(&tempVar55);
        SCLabel->setNotControl(true);
        SCLabel->setText("0/0");
        //Breezer - New Labels
        CritRLabel = new MirLabel();
        CritRLabel->setAutoSize(true);
        CritRLabel->setParent(StatusPage);
        Point tempVar56(126, 146);
        CritRLabel->setLocation(&tempVar56);
        CritRLabel->setNotControl(true);
        CritDLabel = new MirLabel();
        CritDLabel->setAutoSize(true);
        CritDLabel->setParent(StatusPage);
        Point tempVar57(126, 164);
        CritDLabel->setLocation(&tempVar57);
        CritDLabel->setNotControl(true);
        AttkSpdLabel = new MirLabel();
        AttkSpdLabel->setAutoSize(true);
        AttkSpdLabel->setParent(StatusPage);
        Point tempVar58(126, 182);
        AttkSpdLabel->setLocation(&tempVar58);
        AttkSpdLabel->setNotControl(true);
        AccLabel = new MirLabel();
        AccLabel->setAutoSize(true);
        AccLabel->setParent(StatusPage);
        Point tempVar59(126, 200);
        AccLabel->setLocation(&tempVar59);
        AccLabel->setNotControl(true);
        AgilLabel = new MirLabel();
        AgilLabel->setAutoSize(true);
        AgilLabel->setParent(StatusPage);
        Point tempVar60(126, 218);
        AgilLabel->setLocation(&tempVar60);
        AgilLabel->setNotControl(true);
        LuckLabel = new MirLabel();
        LuckLabel->setAutoSize(true);
        LuckLabel->setParent(StatusPage);
        Point tempVar61(126, 236);
        LuckLabel->setLocation(&tempVar61);
        LuckLabel->setNotControl(true);
        // STATS II 
        ExpPLabel = new MirLabel();
        ExpPLabel->setAutoSize(true);
        ExpPLabel->setParent(StatePage);
        Point tempVar62(126, 20);
        ExpPLabel->setLocation(&tempVar62);
        ExpPLabel->setNotControl(true);
        ExpPLabel->setText("0-0");

        BagWLabel = new MirLabel();
        BagWLabel->setAutoSize(true);
        BagWLabel->setParent(StatePage);
        Point tempVar63(126, 38);
        BagWLabel->setLocation(&tempVar63);
        BagWLabel->setNotControl(true);
        BagWLabel->setText("0-0");

        WearWLabel = new MirLabel();
        WearWLabel->setAutoSize(true);
        WearWLabel->setParent(StatePage);
        Point tempVar64(126, 56);
        WearWLabel->setLocation(&tempVar64);
        WearWLabel->setNotControl(true);
        WearWLabel->setText("0-0");

        HandWLabel = new MirLabel();
        HandWLabel->setAutoSize(true);
        HandWLabel->setParent(StatePage);
        Point tempVar65(126, 74);
        HandWLabel->setLocation(&tempVar65);
        HandWLabel->setNotControl(true);
        HandWLabel->setText("0-0");
        MagicRLabel = new MirLabel();
        MagicRLabel->setAutoSize(true);
        MagicRLabel->setParent(StatePage);
        Point tempVar66(126, 92);
        MagicRLabel->setLocation(&tempVar66);
        MagicRLabel->setNotControl(true);
        MagicRLabel->setText("0-0");
        PoisonResLabel = new MirLabel();
        PoisonResLabel->setAutoSize(true);
        PoisonResLabel->setParent(StatePage);
        Point tempVar67(126, 110);
        PoisonResLabel->setLocation(&tempVar67);
        PoisonResLabel->setNotControl(true);
        PoisonResLabel->setText("0/0");
        HealthRLabel = new MirLabel();
        HealthRLabel->setAutoSize(true);
        HealthRLabel->setParent(StatePage);
        Point tempVar68(126, 128);
        HealthRLabel->setLocation(&tempVar68);
        HealthRLabel->setNotControl(true);
        HealthRLabel->setText("0/0");
        //Breezer
        ManaRLabel = new MirLabel();
        ManaRLabel->setAutoSize(true);
        ManaRLabel->setParent(StatePage);
        Point tempVar69(126, 146);
        ManaRLabel->setLocation(&tempVar69);
        ManaRLabel->setNotControl(true);
        PoisonRecLabel = new MirLabel();
        PoisonRecLabel->setAutoSize(true);
        PoisonRecLabel->setParent(StatePage);
        Point tempVar70(126, 164);
        PoisonRecLabel->setLocation(&tempVar70);
        PoisonRecLabel->setNotControl(true);
        HolyTLabel = new MirLabel();
        HolyTLabel->setAutoSize(true);
        HolyTLabel->setParent(StatePage);
        Point tempVar71(126, 182);
        HolyTLabel->setLocation(&tempVar71);
        HolyTLabel->setNotControl(true);
        FreezeLabel = new MirLabel();
        FreezeLabel->setAutoSize(true);
        FreezeLabel->setParent(StatePage);
        Point tempVar72(126, 200);
        FreezeLabel->setLocation(&tempVar72);
        FreezeLabel->setNotControl(true);
        PoisonAtkLabel = new MirLabel();
        PoisonAtkLabel->setAutoSize(true);
        PoisonAtkLabel->setParent(StatePage);
        Point tempVar73(126, 218);
        PoisonAtkLabel->setLocation(&tempVar73);
        PoisonAtkLabel->setNotControl(true);

        Magics = std::vector<MagicButton*>(7);

        for (int i = 0; i < Magics.size(); i++)
        {
            MagicButton *tempVar74 = new MagicButton();
            tempVar74->setParent(SkillPage);
            tempVar74->setVisible(false);
            Point tempVar75(8, 8 + i * 33);
            tempVar74->setLocation(&tempVar75);
            Magics[i] = tempVar74;

            delete tempVar74;
        }

        NextButton = new MirButton();
        NextButton->setIndex(396);
        Point tempVar76(140, 250);
        NextButton->setLocation(&tempVar76);
        NextButton->setLibrary(Libraries::Prguse);
        NextButton->setParent(SkillPage);
        NextButton->setPressedIndex(397);
        NextButton->setSound(SoundList::ButtonA);
        NextButton->Click += [&] (o, e)
        {
            if (StartIndex + 7 >= MapObject::User->Magics.size())
            {
                return;
            }
    
            StartIndex += 7;
            RefreshInterface();
    
            ClearCoolDowns();
        };

        BackButton = new MirButton();
        BackButton->setIndex(398);
        Point tempVar77(90, 250);
        BackButton->setLocation(&tempVar77);
        BackButton->setLibrary(Libraries::Prguse);
        BackButton->setParent(SkillPage);
        BackButton->setPressedIndex(399);
        BackButton->setSound(SoundList::ButtonA);
        BackButton->Click += [&] (o, e)
        {
            if (StartIndex - 7 < 0)
            {
                return;
            }
    
            StartIndex -= 7;
            RefreshInterface();
    
            ClearCoolDowns();
        };

        delete tempVar47;
        delete tempVar45;
        delete tempVar43;
        delete tempVar41;
        delete tempVar39;
        delete tempVar37;
        delete tempVar35;
        delete tempVar33;
        delete tempVar31;
        delete tempVar29;
        delete tempVar27;
        delete tempVar25;
        delete tempVar23;
        delete tempVar21;
    }

    void CharacterDialog::Show()
    {
        if (getVisible())
        {
            return;
        }
        setVisible(true);

        ClearCoolDowns();
    }

    void CharacterDialog::Hide()
    {
        GameScene::Scene->SocketDialog->Hide();
        MirImageControl::Hide();
    }

    void CharacterDialog::ShowCharacterPage()
    {
        CharacterPage->setVisible(true);
        StatusPage->setVisible(false);
        StatePage->setVisible(false);
        SkillPage->setVisible(false);
        CharacterButton->setIndex(500);
        StatusButton->setIndex(-1);
        StateButton->setIndex(-1);
        SkillButton->setIndex(-1);
    }

    void CharacterDialog::ShowStatusPage()
    {
        CharacterPage->setVisible(false);
        StatusPage->setVisible(true);
        StatePage->setVisible(false);
        SkillPage->setVisible(false);
        CharacterButton->setIndex(-1);
        StatusButton->setIndex(501);
        StateButton->setIndex(-1);
        SkillButton->setIndex(-1);
    }

    void CharacterDialog::ShowStatePage()
    {
        CharacterPage->setVisible(false);
        StatusPage->setVisible(false);
        StatePage->setVisible(true);
        SkillPage->setVisible(false);
        CharacterButton->setIndex(-1);
        StatusButton->setIndex(-1);
        StateButton->setIndex(502);
        SkillButton->setIndex(-1);
    }

    void CharacterDialog::ShowSkillPage()
    {
        CharacterPage->setVisible(false);
        StatusPage->setVisible(false);
        StatePage->setVisible(false);
        SkillPage->setVisible(true);
        CharacterButton->setIndex(-1);
        StatusButton->setIndex(-1);
        StateButton->setIndex(-1);
        SkillButton->setIndex(503);
        StartIndex = 0;

        ClearCoolDowns();
    }

    void CharacterDialog::ClearCoolDowns()
    {
        for (int i = 0; i < Magics.size(); i++)
        {
            Magics[i]->CoolDown.Dispose();
        }
    }

    void CharacterDialog::RefreshInterface()
    {
        int offSet = MapObject::User->Gender == MirGender::Male ? 0 : 1;

        setIndex(504); // +offSet;
        CharacterPage->setIndex(340 + offSet);

        switch (MapObject::User->Class)
        {
            case MirClass::Warrior:
                ClassImage->setIndex(100); // + offSet * 5;
                break;
            case MirClass::Wizard:
                ClassImage->setIndex(101); // + offSet * 5;
                break;
            case MirClass::Taoist:
                ClassImage->setIndex(102); // + offSet * 5;
                break;
            case MirClass::Assassin:
                ClassImage->setIndex(103); // + offSet * 5;
                break;
            case MirClass::Archer:
                ClassImage->setIndex(104); // + offSet * 5;
                break;
        }

        NameLabel->setText(MapObject::User->Name);
        GuildLabel->setText(MapObject::User->GuildName + " " + MapObject::User->GuildRankName);

        for (int i = 0; i < Magics.size(); i++)
        {
            if (i + StartIndex >= MapObject::User->Magics.size())
            {
                Magics[i]->setVisible(false);
                continue;
            }

            Magics[i]->setVisible(true);
            Magics[i]->Update(MapObject::User->Magics[i + StartIndex]);
        }
    }

    MirItemCell *CharacterDialog::GetCell(unsigned long long id)
    {

        for (int i = 0; i < Grid.size(); i++)
        {
            if (Grid[i]->getItem() == nullptr || Grid[i]->getItem().UniqueID != id)
            {
                continue;
            }
            return Grid[i];
        }
        return nullptr;
    }

    MiniMapDialog::MiniMapDialog()
    {
        setIndex(2090);
        setLibrary(Libraries::Prguse);
        Point tempVar(Settings::ScreenWidth - 126, 0);
        setLocation(&tempVar);
        setPixelDetect(true);

        BeforeDraw += MiniMap_BeforeDraw;
        AfterDraw += MiniMapDialog_AfterDraw;

        MapNameLabel = new MirLabel();
        MapNameLabel->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::VerticalCenter);
        MapNameLabel->setParent(this);
        Size tempVar2(120, 18);
        MapNameLabel->setSize(&tempVar2);
        Point tempVar3(2, 2);
        MapNameLabel->setLocation(&tempVar3);
        MapNameLabel->setNotControl(true);

        LocationLabel = new MirLabel();
        LocationLabel->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::VerticalCenter);
        LocationLabel->setParent(this);
        Size tempVar4(56, 18);
        LocationLabel->setSize(&tempVar4);
        Point tempVar5(46, 131);
        LocationLabel->setLocation(&tempVar5);
        LocationLabel->setNotControl(true);

        MailButton = new MirButton();
        MailButton->setIndex(2099);
        MailButton->setHoverIndex(2100);
        MailButton->setPressedIndex(2101);
        MailButton->setParent(this);
        Point tempVar6(4, 131);
        MailButton->setLocation(&tempVar6);
        MailButton->setLibrary(Libraries::Prguse);
        MailButton->setSound(SoundList::ButtonA);
        MailButton->setHint(GameLanguage::Mail);
        MailButton->Click += [&] (o, e)
        {
            GameScene::Scene->MailListDialog->Toggle();
        };

        NewMail = new MirImageControl();
        NewMail->setIndex(544);
        Point tempVar7(5, 132);
        NewMail->setLocation(&tempVar7);
        NewMail->setParent(this);
        NewMail->setLibrary(Libraries::Prguse);
        NewMail->setVisible(false);
        NewMail->setNotControl(true);

        BigMapButton = new MirButton();
        BigMapButton->setIndex(2096);
        BigMapButton->setHoverIndex(2097);
        BigMapButton->setPressedIndex(2098);
        BigMapButton->setParent(this);
        Point tempVar8(25, 131);
        BigMapButton->setLocation(&tempVar8);
        BigMapButton->setLibrary(Libraries::Prguse);
        BigMapButton->setSound(SoundList::ButtonA);
        BigMapButton->setHint(std::string::Format(GameLanguage::BigMap, CMain::InputKeys->GetKey(KeybindOptions::Bigmap)));
        BigMapButton->Click += [&] (o, e)
        {
            GameScene::Scene->BigMapDialog->Toggle();
        };

        ToggleButton = new MirButton();
        ToggleButton->setIndex(2102);
        ToggleButton->setHoverIndex(2103);
        ToggleButton->setPressedIndex(2104);
        ToggleButton->setParent(this);
        Point tempVar9(109, 3);
        ToggleButton->setLocation(&tempVar9);
        ToggleButton->setLibrary(Libraries::Prguse);
        ToggleButton->setSound(SoundList::ButtonA);
        ToggleButton->setHint("MiniMap (" + CMain::InputKeys->GetKey(KeybindOptions::Minimap) + ")");
        ToggleButton->Click += [&] (o, e)
        {
            Toggle();
        };

        LightSetting = new MirImageControl();
        LightSetting->setIndex(2093);
        LightSetting->setLibrary(Libraries::Prguse);
        LightSetting->setParent(this);
        Point tempVar10(102, 131);
        LightSetting->setLocation(&tempVar10);


        AModeLabel = new MirLabel();
        AModeLabel->setAutoSize(true);
        AModeLabel->setForeColour(Color::Yellow);
        AModeLabel->setOutLineColour(Color::Black);
        AModeLabel->setParent(this);
        Point tempVar11(115, 125);
        AModeLabel->setLocation(&tempVar11);

        PModeLabel = new MirLabel();
        PModeLabel->setAutoSize(true);
        PModeLabel->setForeColour(Color::Yellow);
        PModeLabel->setOutLineColour(Color::Black);
        PModeLabel->setParent(this);
        Point tempVar12(230, 125);
        PModeLabel->setLocation(&tempVar12);
        PModeLabel->setVisible(false);
    }

    void MiniMapDialog::MiniMapDialog_AfterDraw(std::any sender, EventArgs *e)
    {

    }

    void MiniMapDialog::MiniMap_BeforeDraw(std::any sender, EventArgs *e)
    {

        for (auto icon : QuestIcons)
        {
            icon->Dispose();
        }

        QuestIcons.clear();

        MapControl *map = GameScene::Scene->MapControl;
        if (map == nullptr)
        {
            return;
        }

        if (map->MiniMap == 0 && getIndex() != 2091)
        {
            SetSmallMode();
        }
        else if (map->MiniMap > 0 && _bigMode && getIndex() == 2091)
        {
            SetBigMode();
        }

        if (map->MiniMap <= 0 || getIndex() != 2090 || Libraries::MiniMap == nullptr)
        {
            return;
        }

        Rectangle *viewRect = new Rectangle(0, 0, 120, 108);
        Point *drawLocation = getLocation();
        drawLocation->Offset(3, 22);

        Size *miniMapSize = Libraries::MiniMap->GetSize(map->MiniMap);
        float scaleX = miniMapSize->Width / static_cast<float>(map->Width);
        float scaleY = miniMapSize->Height / static_cast<float>(map->Height);

        viewRect->Location = new Point(static_cast<int>(scaleX * MapObject::User->CurrentLocation->X) - viewRect->Width / 2, static_cast<int>(scaleY * MapObject::User->CurrentLocation->Y) - viewRect->Height / 2);

        //   viewRect.Location = viewRect.Location.Subtract(1, 1);
        if (viewRect->Right >= miniMapSize->Width)
        {
            viewRect->X = miniMapSize->Width - viewRect->Width;
        }
        if (viewRect->Bottom >= miniMapSize->Height)
        {
            viewRect->Y = miniMapSize->Height - viewRect->Height;
        }

        if (viewRect->X < 0)
        {
            viewRect->X = 0;
        }
        if (viewRect->Y < 0)
        {
            viewRect->Y = 0;
        }

        Libraries::MiniMap->Draw(map->MiniMap, viewRect, drawLocation, Color::FromArgb(255, 255, 255), _fade);


        int startPointX = static_cast<int>(viewRect->X / scaleX);
        int startPointY = static_cast<int>(viewRect->Y / scaleY);

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];

            if (ob->getRace() == ObjectType::Item || ob->Dead || ob->getRace() == ObjectType::Spell || ob->Sneaking)
            {
                continue;
            }
            float x = ((ob->CurrentLocation->X - startPointX) * scaleX) + drawLocation->X;
            float y = ((ob->CurrentLocation->Y - startPointY) * scaleY) + drawLocation->Y;

            Color *colour;

            if ((std::find(GroupDialog::GroupList.begin(), GroupDialog::GroupList.end(), ob->Name) != GroupDialog::GroupList.end() && MapObject::User != ob) || ob->Name.EndsWith(StringHelper::formatSimple("({0})", MapObject::User->Name)))
            {
                colour = Color::FromArgb(0, 0, 255);
            }
            else
            {
                if (dynamic_cast<PlayerObject*>(ob) != nullptr)
                {
                colour = Color::FromArgb(255, 255, 255);
                }
            else if (dynamic_cast<NPCObject*>(ob) != nullptr || ob->AI == 6)
            {
                colour = Color::FromArgb(0, 255, 50);
            }
            else
            {
                colour = Color::FromArgb(255, 0, 0);
            }
            }

            Rectangle tempVar(0, 0, 2, 2);
            Vector3 tempVar2(static_cast<float>(x - 0.5), static_cast<float>(y - 0.5), 0.0F);
            DXManager::Sprite->Draw(DXManager::RadarTexture, &tempVar, Vector3::Zero, &tempVar2, colour);

            #pragma region NPC Quest Icons

            NPCObject *npc = dynamic_cast<NPCObject*>(ob);
            if (npc != nullptr && npc->GetAvailableQuests(true).Any())
            {
                std::string text = "";
                Color *color = Color::Empty;

                switch (npc->QuestIcon)
                {
                    case QuestIcon::ExclamationBlue:
                        color = Color::DodgerBlue;
                        text = "!";
                        break;
                    case QuestIcon::ExclamationYellow:
                        color = Color::Yellow;
                        text = "!";
                        break;
                    case QuestIcon::ExclamationGreen:
                        color = Color::Green;
                        text = "!";
                        break;
                    case QuestIcon::QuestionBlue:
                        color = Color::DodgerBlue;
                        text = "?";
                        break;
                    case QuestIcon::QuestionWhite:
                        color = Color::White;
                        text = "?";
                        break;
                    case QuestIcon::QuestionYellow:
                        color = Color::Yellow;
                        text = "?";
                        break;
                    case QuestIcon::QuestionGreen:
                        color = Color::Green;
                        text = "?";
                        break;
                }

                MirLabel *tempVar3 = new MirLabel();
                tempVar3->setAutoSize(true);
                tempVar3->setParent(GameScene::Scene->MiniMapDialog);
                System::Drawing::Font tempVar4(Settings::FontName, 9.0f, FontStyle::Bold);
                tempVar3->setFont(&tempVar4);
                tempVar3->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::VerticalCenter);
                tempVar3->setText(text);
                tempVar3->setForeColour(color);
                Point tempVar5(static_cast<int>(x - Settings::ScreenWidth + GameScene::Scene->MiniMapDialog->getSize()->Width) - 6, static_cast<int>(y) - 10);
                tempVar3->setLocation(&tempVar5);
                tempVar3->setNotControl(true);
                tempVar3->setVisible(true);
                tempVar3->setModal(true);
                QuestIcons.push_back(tempVar3);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar3' statement was not added since tempVar3 was passed to a method or constructor. Handle memory management manually.
            }

            #pragma endregion

        }

//C# TO C++ CONVERTER TODO TASK: A 'delete viewRect' statement was not added since viewRect was passed to a method or constructor. Handle memory management manually.
    }

    void MiniMapDialog::Toggle()
    {
        if (_fade == 0.0F)
        {
            _bigMode = true;
            SetBigMode();
            _fade = 1.0F;
        }
        //else if(_fade == 1F)
        //{
        //    _bigMode = true;
        //    SetBigMode();
        //    _fade = 0.8F;
        //}
        else
        {
            _bigMode = false;
            SetSmallMode();
            _fade = 0;
        }

        Redraw();
    }

    void MiniMapDialog::SetSmallMode()
    {
        setIndex(2091);
        int y = getSize()->Height - 23;
        Point tempVar(4, y);
        MailButton->setLocation(&tempVar);
        Point tempVar2(5, y + 1);
        NewMail->setLocation(&tempVar2);
        Point tempVar3(25, y);
        BigMapButton->setLocation(&tempVar3);
        Point tempVar4(46, y);
        LocationLabel->setLocation(&tempVar4);
        Point tempVar5(102, y);
        LightSetting->setLocation(&tempVar5);

        Point tempVar6(GameScene::Scene->MiniMapDialog->getLocation()->X + 86, GameScene::Scene->MiniMapDialog->getSize()->Height);
        GameScene::Scene->DuraStatusPanel->setLocation(&tempVar6);
    }

    void MiniMapDialog::SetBigMode()
    {
        setIndex(2090);
        int y = getSize()->Height - 23;
        Point tempVar(4, y);
        MailButton->setLocation(&tempVar);
        Point tempVar2(5, y + 1);
        NewMail->setLocation(&tempVar2);
        Point tempVar3(25, y);
        BigMapButton->setLocation(&tempVar3);
        Point tempVar4(46, y);
        LocationLabel->setLocation(&tempVar4);
        Point tempVar5(102, y);
        LightSetting->setLocation(&tempVar5);

        Point tempVar6(GameScene::Scene->MiniMapDialog->getLocation()->X + 86, GameScene::Scene->MiniMapDialog->getSize()->Height);
        GameScene::Scene->DuraStatusPanel->setLocation(&tempVar6);
    }

    void MiniMapDialog::Process()
    {
        MapControl *map = GameScene::Scene->MapControl;
        if (map == nullptr)
        {
            return;
        }

        MapNameLabel->setText(map->Title);
        LocationLabel->setText(Functions::PointToString(MapObject::User->CurrentLocation));

        Point tempVar((GameScene::Scene->MiniMapDialog->getLocation()->X - 3) - GameScene::Scene->MainDialog->getLocation()->X, (GameScene::Scene->MiniMapDialog->getSize()->Height + 150) - Settings::ScreenHeight);
        GameScene::Scene->MainDialog->SModeLabel->setLocation(&tempVar);
        Point tempVar2((GameScene::Scene->MiniMapDialog->getLocation()->X - 3) - GameScene::Scene->MainDialog->getLocation()->X, (GameScene::Scene->MiniMapDialog->getSize()->Height + 165) - Settings::ScreenHeight);
        GameScene::Scene->MainDialog->AModeLabel->setLocation(&tempVar2);
        Point tempVar3((GameScene::Scene->MiniMapDialog->getLocation()->X - 3) - GameScene::Scene->MainDialog->getLocation()->X, (GameScene::Scene->MiniMapDialog->getSize()->Height + 180) - Settings::ScreenHeight);
        GameScene::Scene->MainDialog->PModeLabel->setLocation(&tempVar3);

        if (GameScene::Scene->NewMail)
        {
            double time = (CMain::Time) / 100;

            if (BankersRounding::round(time) % 10 < 5 || GameScene::Scene->NewMailCounter >= 10)
            {
                NewMail->setVisible(true);
            }
            else
            {
                if (NewMail->getVisible())
                {
                    GameScene::Scene->NewMailCounter++;
                }

                NewMail->setVisible(false);
            }
        }
        else
        {
            NewMail->setVisible(false);
        }
    }

std::vector<UserItem*> InspectDialog::Items(14);
unsigned int InspectDialog::InspectID = 0;

    InspectDialog::InspectDialog()
    {
        setIndex(430);
        setLibrary(Libraries::Prguse);
        Point tempVar(536, 0);
        setLocation(&tempVar);
        setMovable(true);
        setSort(true);

        CharacterPage = new MirImageControl();
        CharacterPage->setIndex(340);
        CharacterPage->setParent(this);
        CharacterPage->setLibrary(Libraries::Prguse);
        Point tempVar2(8, 70);
        CharacterPage->setLocation(&tempVar2);
        CharacterPage->AfterDraw += [&] (o, e)
        {
            if (Libraries::StateItems == nullptr)
            {
                return;
            }
    
            ItemInfo *RealItem = nullptr;
    
            if (ArmorCell->getItem() != nullptr)
            {
                RealItem = Functions::GetRealItem(ArmorCell->getItem()->Info, Level, Class, GameScene::ItemInfoList);
                Point tempVar3(getDisplayLocation()->X + 0, getDisplayLocation()->Y + -20);
                Libraries::StateItems->Draw(RealItem->Image, &tempVar3, Color::White, true, 1.0F);
    
                if (RealItem->Effect > 0)
                {
                    int wingOffset = RealItem->Effect == 1 ? 2 : 4;
    
                    int genderOffset = MapObject::User->Gender == MirGender::Male ? 0 : 1;
    
                    Point tempVar4(getDisplayLocation()->X, getDisplayLocation()->Y - 20);
                    Libraries::Prguse2->DrawBlend(1200 + wingOffset + genderOffset, &tempVar4, Color::White, true, 1.0F);
                }
            }
    
            if (WeaponCell->getItem() != nullptr)
            {
                RealItem = Functions::GetRealItem(WeaponCell->getItem()->Info, Level, Class, GameScene::ItemInfoList);
                Point tempVar5(getDisplayLocation()->X, getDisplayLocation()->Y - 20);
                Libraries::StateItems->Draw(RealItem->Image, &tempVar5, Color::White, true, 1.0F);
    
            }
    
            if (HelmetCell->getItem() != nullptr)
            {
                Point tempVar6(getDisplayLocation()->X, getDisplayLocation()->Y - 20);
                Libraries::StateItems->Draw(HelmetCell->getItem()->Info->Image, &tempVar6, Color::White, true, 1.0F);
            }
            else
            {
                int hair = 441 + Hair + (Class == MirClass::Assassin ? 20 : 0) + (Gender == MirGender::Male ? 0 : 40);
    
                int offSetX = Class == MirClass::Assassin ? (Gender == MirGender::Male ? 6 : 4) : 0;
                int offSetY = Class == MirClass::Assassin ? (Gender == MirGender::Male ? 25 : 18) : 0;
    
                Point tempVar7(getDisplayLocation()->X + offSetX, getDisplayLocation()->Y + offSetY - 20);
                Libraries::Prguse->Draw(hair, &tempVar7, Color::White, true, 1.0F);
            }
        };


        CloseButton = new MirButton();
        CloseButton->setHoverIndex(361);
        CloseButton->setIndex(360);
        Point tempVar8(241, 3);
        CloseButton->setLocation(&tempVar8);
        CloseButton->setLibrary(Libraries::Prguse2);
        CloseButton->setParent(this);
        CloseButton->setPressedIndex(362);
        CloseButton->setSound(SoundList::ButtonA);
        CloseButton->Click += [&] (o, e)
        {
            Hide();
        };



        GroupButton = new MirButton();
        GroupButton->setHoverIndex(432);
        GroupButton->setIndex(431);
        Point tempVar9(75, 357);
        GroupButton->setLocation(&tempVar9);
        GroupButton->setLibrary(Libraries::Prguse);
        GroupButton->setParent(this);
        GroupButton->setPressedIndex(433);
        GroupButton->setSound(SoundList::ButtonA);
        GroupButton->setHint("Invite to Group");
        GroupButton->Click += [&] (o, e)
        {
    
            if (GroupDialog::GroupList.size() >= Globals::MaxGroup)
            {
                GameScene::Scene->ChatDialog->ReceiveChat("Your group already has the maximum number of members.", ChatType::System);
                return;
            }
            if (GroupDialog::GroupList.size() > 0 && GroupDialog::GroupList[0] != MapObject::User->Name)
            {
    
                GameScene::Scene->ChatDialog->ReceiveChat("You are not the leader of your group.", ChatType::System);
            }
    
            C::AddMember *tempVar10 = new C::AddMember();
            tempVar10->Name = Name;
            Network::Enqueue(tempVar10);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
            return;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar10' statement was not added since tempVar10 was passed to a method or constructor. Handle memory management manually.
        };

        FriendButton = new MirButton();
        FriendButton->setHoverIndex(435);
        FriendButton->setIndex(434);
        Point tempVar11(105, 357);
        FriendButton->setLocation(&tempVar11);
        FriendButton->setLibrary(Libraries::Prguse);
        FriendButton->setParent(this);
        FriendButton->setPressedIndex(436);
        FriendButton->setSound(SoundList::ButtonA);
        FriendButton->setHint("Add to Friends List");
        FriendButton->Click += [&] (o, e)
        {
            C::AddFriend *tempVar12 = new C::AddFriend();
            tempVar12->Name = Name;
            tempVar12->Blocked = false;
            Network::Enqueue(tempVar12);

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar12' statement was not added since tempVar12 was passed to a method or constructor. Handle memory management manually.
        };

        MailButton = new MirButton();
        MailButton->setHoverIndex(438);
        MailButton->setIndex(437);
        Point tempVar13(135, 357);
        MailButton->setLocation(&tempVar13);
        MailButton->setLibrary(Libraries::Prguse);
        MailButton->setParent(this);
        MailButton->setPressedIndex(439);
        MailButton->setSound(SoundList::ButtonA);
        MailButton->setHint("Send Mail");
        MailButton->Click += [&] (o, e)
        {
            GameScene::Scene->MailComposeLetterDialog->ComposeMail(Name);
        };

        TradeButton = new MirButton();
        TradeButton->setHoverIndex(524);
        TradeButton->setIndex(523);
        Point tempVar14(165, 357);
        TradeButton->setLocation(&tempVar14);
        TradeButton->setLibrary(Libraries::Prguse);
        TradeButton->setParent(this);
        TradeButton->setPressedIndex(525);
        TradeButton->setSound(SoundList::ButtonA);
        TradeButton->setHint("Trade");
        TradeButton->Click += [&] (o, e)
        {
            C::TradeRequest tempVar15();
            Network::Enqueue(&tempVar15);
        };

        NameLabel = new MirLabel();
        NameLabel->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::VerticalCenter);
        NameLabel->setParent(this);
        Point tempVar16(50, 12);
        NameLabel->setLocation(&tempVar16);
        Size tempVar17(190, 20);
        NameLabel->setSize(&tempVar17);
        NameLabel->setNotControl(true);
        NameLabel->Click += [&] (o, e)
        {
            GameScene::Scene->ChatDialog->ChatTextBox->SetFocus();
            GameScene::Scene->ChatDialog->ChatTextBox->setText(StringHelper::formatSimple("/{0} ", Name));
            GameScene::Scene->ChatDialog->ChatTextBox->setVisible(true);
            GameScene::Scene->ChatDialog->ChatTextBox->TextBox->SelectionLength = 0;
            GameScene::Scene->ChatDialog->ChatTextBox->TextBox->SelectionStart = Name.length() + 2;
    
        };
        LoverButton = new MirButton();
        LoverButton->setIndex(604);
        Point tempVar18(17, 17);
        LoverButton->setLocation(&tempVar18);
        LoverButton->setLibrary(Libraries::Prguse);
        LoverButton->setParent(this);
        LoverButton->setSound(SoundList::None);

        GuildLabel = new MirLabel();
        GuildLabel->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::VerticalCenter);
        GuildLabel->setParent(this);
        Point tempVar19(50, 33);
        GuildLabel->setLocation(&tempVar19);
        Size tempVar20(190, 30);
        GuildLabel->setSize(&tempVar20);
        GuildLabel->setNotControl(true);

        ClassImage = new MirImageControl();
        ClassImage->setIndex(100);
        ClassImage->setLibrary(Libraries::Prguse);
        Point tempVar21(15, 33);
        ClassImage->setLocation(&tempVar21);
        ClassImage->setParent(this);
        ClassImage->setNotControl(true);


        WeaponCell = new MirItemCell();
        WeaponCell->setItemSlot(static_cast<int>(EquipmentSlot::Weapon));
        WeaponCell->setGridType(MirGridType::Inspect);
        WeaponCell->setParent(CharacterPage);
        Point tempVar22(123, 7);
        WeaponCell->setLocation(&tempVar22);

        ArmorCell = new MirItemCell();
        ArmorCell->setItemSlot(static_cast<int>(EquipmentSlot::Armour));
        ArmorCell->setGridType(MirGridType::Inspect);
        ArmorCell->setParent(CharacterPage);
        Point tempVar23(163, 7);
        ArmorCell->setLocation(&tempVar23);

        HelmetCell = new MirItemCell();
        HelmetCell->setItemSlot(static_cast<int>(EquipmentSlot::Helmet));
        HelmetCell->setGridType(MirGridType::Inspect);
        HelmetCell->setParent(CharacterPage);
        Point tempVar24(203, 7);
        HelmetCell->setLocation(&tempVar24);


        TorchCell = new MirItemCell();
        TorchCell->setItemSlot(static_cast<int>(EquipmentSlot::Torch));
        TorchCell->setGridType(MirGridType::Inspect);
        TorchCell->setParent(CharacterPage);
        Point tempVar25(203, 134);
        TorchCell->setLocation(&tempVar25);

        NecklaceCell = new MirItemCell();
        NecklaceCell->setItemSlot(static_cast<int>(EquipmentSlot::Necklace));
        NecklaceCell->setGridType(MirGridType::Inspect);
        NecklaceCell->setParent(CharacterPage);
        Point tempVar26(203, 98);
        NecklaceCell->setLocation(&tempVar26);

        BraceletLCell = new MirItemCell();
        BraceletLCell->setItemSlot(static_cast<int>(EquipmentSlot::BraceletL));
        BraceletLCell->setGridType(MirGridType::Inspect);
        BraceletLCell->setParent(CharacterPage);
        Point tempVar27(8, 170);
        BraceletLCell->setLocation(&tempVar27);
        BraceletRCell = new MirItemCell();
        BraceletRCell->setItemSlot(static_cast<int>(EquipmentSlot::BraceletR));
        BraceletRCell->setGridType(MirGridType::Inspect);
        BraceletRCell->setParent(CharacterPage);
        Point tempVar28(203, 170);
        BraceletRCell->setLocation(&tempVar28);
        RingLCell = new MirItemCell();
        RingLCell->setItemSlot(static_cast<int>(EquipmentSlot::RingL));
        RingLCell->setGridType(MirGridType::Inspect);
        RingLCell->setParent(CharacterPage);
        Point tempVar29(8, 206);
        RingLCell->setLocation(&tempVar29);
        RingRCell = new MirItemCell();
        RingRCell->setItemSlot(static_cast<int>(EquipmentSlot::RingR));
        RingRCell->setGridType(MirGridType::Inspect);
        RingRCell->setParent(CharacterPage);
        Point tempVar30(203, 206);
        RingRCell->setLocation(&tempVar30);

        AmuletCell = new MirItemCell();
        AmuletCell->setItemSlot(static_cast<int>(EquipmentSlot::Amulet));
        AmuletCell->setGridType(MirGridType::Inspect);
        AmuletCell->setParent(CharacterPage);
        Point tempVar31(8, 242);
        AmuletCell->setLocation(&tempVar31);

        BootsCell = new MirItemCell();
        BootsCell->setItemSlot(static_cast<int>(EquipmentSlot::Boots));
        BootsCell->setGridType(MirGridType::Inspect);
        BootsCell->setParent(CharacterPage);
        Point tempVar32(48, 242);
        BootsCell->setLocation(&tempVar32);
        BeltCell = new MirItemCell();
        BeltCell->setItemSlot(static_cast<int>(EquipmentSlot::Belt));
        BeltCell->setGridType(MirGridType::Inspect);
        BeltCell->setParent(CharacterPage);
        Point tempVar33(88, 242);
        BeltCell->setLocation(&tempVar33);

        StoneCell = new MirItemCell();
        StoneCell->setItemSlot(static_cast<int>(EquipmentSlot::Stone));
        StoneCell->setGridType(MirGridType::Inspect);
        StoneCell->setParent(CharacterPage);
        Point tempVar34(128, 242);
        StoneCell->setLocation(&tempVar34);

        MountCell = new MirItemCell();
        MountCell->setItemSlot(static_cast<int>(EquipmentSlot::Mount));
        MountCell->setGridType(MirGridType::Inspect);
        MountCell->setParent(CharacterPage);
        Point tempVar35(203, 62);
        MountCell->setLocation(&tempVar35);
    }

    void InspectDialog::RefreshInferface()
    {
        int offSet = Gender == MirGender::Male ? 0 : 1;

        CharacterPage->setIndex(340 + offSet);

        switch (Class)
        {
            case MirClass::Warrior:
                ClassImage->setIndex(100); // + offSet * 5;
                break;
            case MirClass::Wizard:
                ClassImage->setIndex(101); // + offSet * 5;
                break;
            case MirClass::Taoist:
                ClassImage->setIndex(102); // + offSet * 5;
                break;
            case MirClass::Assassin:
                ClassImage->setIndex(103); // + offSet * 5;
                break;
            case MirClass::Archer:
                ClassImage->setIndex(104); // + offSet * 5;
                break;
        }

        NameLabel->setText(Name);
        GuildLabel->setText(GuildName + " " + GuildRank);
        if (LoverName != "")
        {
            LoverButton->setVisible(true);
            LoverButton->setHint(LoverName);
        }
        else
        {
            LoverButton->setVisible(false);
        }


        for (int i = 0; i < Items.size(); i++)
        {
            if (Items[i] == nullptr)
            {
                continue;
            }
            GameScene::Bind(Items[i]);
        }
    }

    OptionDialog::OptionDialog()
    {
        setIndex(411);
        setLibrary(Libraries::Title);
        setMovable(true);
        setSort(true);

        Point tempVar((Settings::ScreenWidth - getSize()->Width) / 2, (Settings::ScreenHeight - getSize()->Height) / 2);
        setLocation(&tempVar);

        BeforeDraw += OptionPanel_BeforeDraw;

        CloseButton = new MirButton();
        CloseButton->setIndex(360);
        CloseButton->setHoverIndex(361);
        CloseButton->setLibrary(Libraries::Prguse2);
        Point tempVar2(getSize()->Width - 26, 5);
        CloseButton->setLocation(&tempVar2);
        CloseButton->setParent(this);
        CloseButton->setSound(SoundList::ButtonA);
        CloseButton->setPressedIndex(362);
        CloseButton->Click += [&] (o, e)
        {
            Hide();
        };

        //tilde option
        SkillModeOn = new MirButton();
        SkillModeOn->setLibrary(Libraries::Prguse2);
        Point tempVar3(159, 68);
        SkillModeOn->setLocation(&tempVar3);
        SkillModeOn->setParent(this);
        SkillModeOn->setSound(SoundList::ButtonA);
        Size tempVar4(36, 17);
        SkillModeOn->setSize(&tempVar4);
        SkillModeOn->setPressedIndex(451);
        SkillModeOn->Click += [&] (o, e)
        {
            GameScene::Scene->ChangeSkillMode(std::make_optional(false));
        };

        //ctrl option
        SkillModeOff = new MirButton();
        SkillModeOff->setLibrary(Libraries::Prguse2);
        Point tempVar5(201, 68);
        SkillModeOff->setLocation(&tempVar5);
        SkillModeOff->setParent(this);
        SkillModeOff->setSound(SoundList::ButtonA);
        Size tempVar6(36, 17);
        SkillModeOff->setSize(&tempVar6);
        SkillModeOff->setPressedIndex(454);
        SkillModeOff->Click += [&] (o, e)
        {
            GameScene::Scene->ChangeSkillMode(std::make_optional(true));
        };

        SkillBarOn = new MirButton();
        SkillBarOn->setLibrary(Libraries::Prguse2);
        Point tempVar7(159, 93);
        SkillBarOn->setLocation(&tempVar7);
        SkillBarOn->setParent(this);
        SkillBarOn->setSound(SoundList::ButtonA);
        Size tempVar8(36, 17);
        SkillBarOn->setSize(&tempVar8);
        SkillBarOn->setPressedIndex(457);
        SkillBarOn->Click += [&] (o, e)
        {
            Settings::SkillBar = true;
        };

        SkillBarOff = new MirButton();
        SkillBarOff->setLibrary(Libraries::Prguse2);
        Point tempVar9(201, 93);
        SkillBarOff->setLocation(&tempVar9);
        SkillBarOff->setParent(this);
        SkillBarOff->setSound(SoundList::ButtonA);
        Size tempVar10(36, 17);
        SkillBarOff->setSize(&tempVar10);
        SkillBarOff->setPressedIndex(460);
        SkillBarOff->Click += [&] (o, e)
        {
            Settings::SkillBar = false;
        };

        EffectOn = new MirButton();
        EffectOn->setLibrary(Libraries::Prguse2);
        Point tempVar11(159, 118);
        EffectOn->setLocation(&tempVar11);
        EffectOn->setParent(this);
        EffectOn->setSound(SoundList::ButtonA);
        Size tempVar12(36, 17);
        EffectOn->setSize(&tempVar12);
        EffectOn->setPressedIndex(457);
        EffectOn->Click += [&] (o, e)
        {
            Settings::Effect = true;
        };

        EffectOff = new MirButton();
        EffectOff->setLibrary(Libraries::Prguse2);
        Point tempVar13(201, 118);
        EffectOff->setLocation(&tempVar13);
        EffectOff->setParent(this);
        EffectOff->setSound(SoundList::ButtonA);
        Size tempVar14(36, 17);
        EffectOff->setSize(&tempVar14);
        EffectOff->setPressedIndex(460);
        EffectOff->Click += [&] (o, e)
        {
            Settings::Effect = false;
        };

        DropViewOn = new MirButton();
        DropViewOn->setLibrary(Libraries::Prguse2);
        Point tempVar15(159, 143);
        DropViewOn->setLocation(&tempVar15);
        DropViewOn->setParent(this);
        DropViewOn->setSound(SoundList::ButtonA);
        Size tempVar16(36, 17);
        DropViewOn->setSize(&tempVar16);
        DropViewOn->setPressedIndex(457);
        DropViewOn->Click += [&] (o, e)
        {
            Settings::DropView = true;
        };

        DropViewOff = new MirButton();
        DropViewOff->setLibrary(Libraries::Prguse2);
        Point tempVar17(201, 143);
        DropViewOff->setLocation(&tempVar17);
        DropViewOff->setParent(this);
        DropViewOff->setSound(SoundList::ButtonA);
        Size tempVar18(36, 17);
        DropViewOff->setSize(&tempVar18);
        DropViewOff->setPressedIndex(460);
        DropViewOff->Click += [&] (o, e)
        {
            Settings::DropView = false;
        };

        NameViewOn = new MirButton();
        NameViewOn->setLibrary(Libraries::Prguse2);
        Point tempVar19(159, 168);
        NameViewOn->setLocation(&tempVar19);
        NameViewOn->setParent(this);
        NameViewOn->setSound(SoundList::ButtonA);
        Size tempVar20(36, 17);
        NameViewOn->setSize(&tempVar20);
        NameViewOn->setPressedIndex(457);
        NameViewOn->Click += [&] (o, e)
        {
            Settings::NameView = true;
        };

        NameViewOff = new MirButton();
        NameViewOff->setLibrary(Libraries::Prguse2);
        Point tempVar21(201, 168);
        NameViewOff->setLocation(&tempVar21);
        NameViewOff->setParent(this);
        NameViewOff->setSound(SoundList::ButtonA);
        Size tempVar22(36, 17);
        NameViewOff->setSize(&tempVar22);
        NameViewOff->setPressedIndex(460);
        NameViewOff->Click += [&] (o, e)
        {
            Settings::NameView = false;
        };

        HPViewOn = new MirButton();
        HPViewOn->setLibrary(Libraries::Prguse2);
        Point tempVar23(159, 193);
        HPViewOn->setLocation(&tempVar23);
        HPViewOn->setParent(this);
        HPViewOn->setSound(SoundList::ButtonA);
        Size tempVar24(36, 17);
        HPViewOn->setSize(&tempVar24);
        HPViewOn->setPressedIndex(463);
        HPViewOn->Click += [&] (o, e)
        {
            Settings::HPView = true;
            GameScene::Scene->ChatDialog->ReceiveChat("[HP/MP Mode 1]", ChatType::Hint);
        };

        HPViewOff = new MirButton();
        HPViewOff->setLibrary(Libraries::Prguse2);
        Point tempVar25(201, 193);
        HPViewOff->setLocation(&tempVar25);
        HPViewOff->setParent(this);
        HPViewOff->setSound(SoundList::ButtonA);
        Size tempVar26(36, 17);
        HPViewOff->setSize(&tempVar26);
        HPViewOff->setPressedIndex(466);
        HPViewOff->Click += [&] (o, e)
        {
            Settings::HPView = false;
            GameScene::Scene->ChatDialog->ReceiveChat("[HP/MP Mode 2]", ChatType::Hint);
        };

        SoundBar = new MirImageControl();
        SoundBar->setIndex(468);
        SoundBar->setLibrary(Libraries::Prguse2);
        Point tempVar27(159, 225);
        SoundBar->setLocation(&tempVar27);
        SoundBar->setParent(this);
        SoundBar->setDrawImage(false);
        SoundBar->MouseDown += SoundBar_MouseMove;
        SoundBar->MouseMove += SoundBar_MouseMove;
        SoundBar->BeforeDraw += SoundBar_BeforeDraw;

        VolumeBar = new MirImageControl();
        VolumeBar->setIndex(20);
        VolumeBar->setLibrary(Libraries::Prguse);
        Point tempVar28(155, 218);
        VolumeBar->setLocation(&tempVar28);
        VolumeBar->setParent(this);
        VolumeBar->setNotControl(true);

        MusicSoundBar = new MirImageControl();
        MusicSoundBar->setIndex(468);
        MusicSoundBar->setLibrary(Libraries::Prguse2);
        Point tempVar29(159, 251);
        MusicSoundBar->setLocation(&tempVar29);
        MusicSoundBar->setParent(this);
        MusicSoundBar->setDrawImage(false);
        MusicSoundBar->MouseDown += MusicSoundBar_MouseMove;
        MusicSoundBar->MouseMove += MusicSoundBar_MouseMove;
        MusicSoundBar->MouseUp->addListener("MusicSoundBar_MouseUp", std::bind(&OptionDialog::MusicSoundBar_MouseUp, this, std::placeholders::_1, std::placeholders::_2));
        MusicSoundBar->BeforeDraw += MusicSoundBar_BeforeDraw;

        MusicVolumeBar = new MirImageControl();
        MusicVolumeBar->setIndex(20);
        MusicVolumeBar->setLibrary(Libraries::Prguse);
        Point tempVar30(155, 244);
        MusicVolumeBar->setLocation(&tempVar30);
        MusicVolumeBar->setParent(this);
        MusicVolumeBar->setNotControl(true);

    }

    void OptionDialog::ToggleSkillButtons(bool Ctrl)
    {
        for (auto KeyCheck : CMain::InputKeys->Keylist)
        {
            if (KeyCheck->Key == Keys->None)
            {
                continue;
            }
            if ((KeyCheck->function < KeybindOptions::Bar1Skill1) || (KeyCheck->function > KeybindOptions::Bar2Skill8))
            {
                continue;
            }
            //need to test this 
            if ((KeyCheck->RequireCtrl != 1) && (KeyCheck->RequireTilde != 1))
            {
                continue;
            }
            KeyCheck->RequireCtrl = static_cast<unsigned char>(Ctrl ? 1 : 0);
            KeyCheck->RequireTilde = static_cast<unsigned char>(Ctrl ? 0 : 1);
        }
    }

    void OptionDialog::SoundBar_MouseMove(std::any sender, MouseEventArgs *e)
    {
        if (e->Button != MouseButtons->Left || SoundBar != ActiveControl)
        {
            return;
        }

        Point *p = e->Location->Subtract(SoundBar->getDisplayLocation());

        unsigned char volume = static_cast<unsigned char>(p->X / static_cast<double>(SoundBar->getSize()->Width) * 100);
        Settings::setVolume(volume);


        double percent = Settings::getVolume() / 100;
        if (percent > 1)
        {
            percent = 1;
        }

        Point tempVar(159, 218);
        VolumeBar->setLocation(percent > 0 ? new Point(159 + static_cast<int>((SoundBar->getSize()->Width - 2) * percent), 218) : &tempVar);
    }

    void OptionDialog::SoundBar_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (SoundBar->getLibrary() == nullptr)
        {
            return;
        }

        double percent = Settings::getVolume() / 100;
        if (percent > 1)
        {
            percent = 1;
        }
        if (percent > 0)
        {
            Rectangle *section = new Rectangle();
            section->Size = new Size(static_cast<int>((SoundBar->getSize()->Width - 2) * percent), SoundBar->getSize()->Height);

            SoundBar->getLibrary()->Draw(SoundBar->getIndex(), section, SoundBar->getDisplayLocation(), Color::White, false);
            Point tempVar(159 + section->Size->Width, 218);
            VolumeBar->setLocation(&tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete section' statement was not added since section was passed to a method or constructor. Handle memory management manually.
        }
        else
        {
            Point tempVar2(159, 218);
            VolumeBar->setLocation(&tempVar2);
        }
    }

    void OptionDialog::MusicSoundBar_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (MusicSoundBar->getLibrary() == nullptr)
        {
            return;
        }

        double percent = Settings::getMusicVolume() / 100;
        if (percent > 1)
        {
            percent = 1;
        }
        if (percent > 0)
        {
            Rectangle *section = new Rectangle();
            section->Size = new Size(static_cast<int>((MusicSoundBar->getSize()->Width - 2) * percent), MusicSoundBar->getSize()->Height);

            MusicSoundBar->getLibrary()->Draw(MusicSoundBar->getIndex(), section, MusicSoundBar->getDisplayLocation(), Color::White, false);
            Point tempVar(159 + section->Size->Width, 244);
            MusicVolumeBar->setLocation(&tempVar);

//C# TO C++ CONVERTER TODO TASK: A 'delete section' statement was not added since section was passed to a method or constructor. Handle memory management manually.
        }
        else
        {
            Point tempVar2(159, 244);
            MusicVolumeBar->setLocation(&tempVar2);
        }
    }

    void OptionDialog::MusicSoundBar_MouseUp(std::any sender, MouseEventArgs *e)
    {
        if (SoundManager::getMusicVol() <= -2900)
        {
            SoundManager::setMusicVol(-3000);
        }
        if (SoundManager::getMusicVol() >= -100)
        {
            SoundManager::setMusicVol(0);
        }


        //SoundManager.Device.Dispose();
        //SoundManager.Create();
        //SoundManager.PlayMusic(SoundList.Music, true);

        if (SoundManager::Music == nullptr)
        {
            return;
        }

        SoundManager::Music->SetVolume(SoundManager::getMusicVol());

    }

    void OptionDialog::MusicSoundBar_MouseMove(std::any sender, MouseEventArgs *e)
    {
        if (e->Button != MouseButtons->Left || MusicSoundBar != ActiveControl)
        {
            return;
        }

        Point *p = e->Location->Subtract(MusicSoundBar->getDisplayLocation());

        unsigned char volume = static_cast<unsigned char>(p->X / static_cast<double>(MusicSoundBar->getSize()->Width) * 100);
        Settings::setMusicVolume(volume);


        double percent = Settings::getMusicVolume() / 100;
        if (percent > 1)
        {
            percent = 1;
        }

        Point tempVar(159, 244);
        MusicVolumeBar->setLocation(percent > 0 ? new Point(159 + static_cast<int>((MusicSoundBar->getSize()->Width - 2) * percent), 244) : &tempVar);
    }

    void OptionDialog::OptionPanel_BeforeDraw(std::any sender, EventArgs *e)
    {
        if (Settings::SkillMode)
        {
            SkillModeOn->setIndex(452);
            SkillModeOff->setIndex(453);
        }
        else
        {
            SkillModeOn->setIndex(450);
            SkillModeOff->setIndex(455);
        }

        if (Settings::SkillBar)
        {
            SkillBarOn->setIndex(458);
            SkillBarOff->setIndex(459);
        }
        else
        {
            SkillBarOn->setIndex(456);
            SkillBarOff->setIndex(461);
        }

        if (Settings::Effect)
        {
            EffectOn->setIndex(458);
            EffectOff->setIndex(459);
        }
        else
        {
            EffectOn->setIndex(456);
            EffectOff->setIndex(461);
        }

        if (Settings::DropView)
        {
            DropViewOn->setIndex(458);
            DropViewOff->setIndex(459);
        }
        else
        {
            DropViewOn->setIndex(456);
            DropViewOff->setIndex(461);
        }

        if (Settings::NameView)
        {
            NameViewOn->setIndex(458);
            NameViewOff->setIndex(459);
        }
        else
        {
            NameViewOn->setIndex(456);
            NameViewOff->setIndex(461);
        }

        if (Settings::HPView)
        {
            HPViewOn->setIndex(464);
            HPViewOff->setIndex(465);
        }
        else
        {
            HPViewOn->setIndex(462);
            HPViewOff->setIndex(467);
        }


    }

    MenuDialog::MenuDialog()
    {
        setIndex(567);
        setParent(GameScene::Scene);
        setLibrary(Libraries::Title);
        Point tempVar(Settings::ScreenWidth - getSize()->Width, GameScene::Scene->MainDialog->getLocation()->Y - this->getSize()->Height + 15);
        setLocation(&tempVar);
        setSort(true);
        setVisible(false);
        setMovable(true);

        ExitButton = new MirButton();
        ExitButton->setHoverIndex(634);
        ExitButton->setIndex(633);
        ExitButton->setParent(this);
        ExitButton->setLibrary(Libraries::Title);
        Point tempVar2(3, 12);
        ExitButton->setLocation(&tempVar2);
        ExitButton->setPressedIndex(635);
        ExitButton->setHint(std::string::Format(GameLanguage::Exit, CMain::InputKeys->GetKey(KeybindOptions::Exit)));
        ExitButton->Click += [&] (o, e)
        {
            GameScene::Scene->QuitGame();
        };

        LogOutButton = new MirButton();
        LogOutButton->setHoverIndex(637);
        LogOutButton->setIndex(636);
        LogOutButton->setParent(this);
        LogOutButton->setLibrary(Libraries::Title);
        Point tempVar3(3, 31);
        LogOutButton->setLocation(&tempVar3);
        LogOutButton->setPressedIndex(638);
        LogOutButton->setHint(std::string::Format(GameLanguage::LogOut, CMain::InputKeys->GetKey(KeybindOptions::Logout)));
        LogOutButton->Click += [&] (o, e)
        {
            GameScene::Scene->LogOut();
        };


        HelpButton = new MirButton();
        HelpButton->setIndex(1970);
        HelpButton->setHoverIndex(1971);
        HelpButton->setPressedIndex(1972);
        HelpButton->setParent(this);
        HelpButton->setLibrary(Libraries::Prguse);
        Point tempVar4(3, 50);
        HelpButton->setLocation(&tempVar4);
        HelpButton->setHint(std::string::Format(GameLanguage::Help, CMain::InputKeys->GetKey(KeybindOptions::Help)));
        HelpButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->HelpDialog->getVisible())
            {
                GameScene::Scene->HelpDialog->Hide();
            }
            else
            {
                GameScene::Scene->HelpDialog->Show();
            }
        };

        KeyboardLayoutButton = new MirButton();
        KeyboardLayoutButton->setIndex(1973);
        KeyboardLayoutButton->setHoverIndex(1974);
        KeyboardLayoutButton->setPressedIndex(1975);
        KeyboardLayoutButton->setParent(this);
        KeyboardLayoutButton->setLibrary(Libraries::Prguse);
        Point tempVar5(3, 69);
        KeyboardLayoutButton->setLocation(&tempVar5);
        KeyboardLayoutButton->setVisible(true);
        KeyboardLayoutButton->setHint("Keyboard (" + CMain::InputKeys->GetKey(KeybindOptions::Keybind) + ")");
        KeyboardLayoutButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->KeyboardLayoutDialog->getVisible())
            {
                GameScene::Scene->KeyboardLayoutDialog->Hide();
            }
            else
            {
                GameScene::Scene->KeyboardLayoutDialog->Show();
            }
        };

        RankingButton = new MirButton();
        RankingButton->setIndex(2000);
        RankingButton->setHoverIndex(2001);
        RankingButton->setPressedIndex(2002);
        RankingButton->setParent(this);
        RankingButton->setLibrary(Libraries::Prguse);
        Point tempVar6(3, 88);
        RankingButton->setLocation(&tempVar6);
        RankingButton->setHint(std::string::Format(GameLanguage::Ranking, CMain::InputKeys->GetKey(KeybindOptions::Ranking)));
        RankingButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->RankingDialog->getVisible())
            {
                GameScene::Scene->RankingDialog->Hide();
            }
            else
            {
                GameScene::Scene->RankingDialog->Show();
            }
        };

        CraftingButton = new MirButton();
        CraftingButton->setIndex(2000);
        CraftingButton->setHoverIndex(2001);
        CraftingButton->setPressedIndex(2002);
        CraftingButton->setParent(this);
        CraftingButton->setLibrary(Libraries::Prguse);
        Point tempVar7(3, 107);
        CraftingButton->setLocation(&tempVar7);
        CraftingButton->setVisible(false);
        CraftingButton->Click += [&] (o, e)
        {
    
        };

        IntelligentCreatureButton = new MirButton();
        IntelligentCreatureButton->setIndex(431);
        IntelligentCreatureButton->setHoverIndex(432);
        IntelligentCreatureButton->setPressedIndex(433);
        IntelligentCreatureButton->setParent(this);
        IntelligentCreatureButton->setLibrary(Libraries::Prguse2);
        Point tempVar8(3, 126);
        IntelligentCreatureButton->setLocation(&tempVar8);
        IntelligentCreatureButton->setHint(std::string::Format(GameLanguage::Creatures, CMain::InputKeys->GetKey(KeybindOptions::Creature)));
        IntelligentCreatureButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->IntelligentCreatureDialog->getVisible())
            {
                GameScene::Scene->IntelligentCreatureDialog->Hide();
            }
            else
            {
                GameScene::Scene->IntelligentCreatureDialog->Show();
            }
        };
        RideButton = new MirButton();
        RideButton->setIndex(1976);
        RideButton->setHoverIndex(1977);
        RideButton->setPressedIndex(1978);
        RideButton->setParent(this);
        RideButton->setLibrary(Libraries::Prguse);
        Point tempVar9(3, 145);
        RideButton->setLocation(&tempVar9);
        RideButton->setHint(std::string::Format(GameLanguage::Mount, CMain::InputKeys->GetKey(KeybindOptions::MountWindow)));
        RideButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->MountDialog->getVisible())
            {
                GameScene::Scene->MountDialog->Hide();
            }
            else
            {
                GameScene::Scene->MountDialog->Show();
            }
        };

        FishingButton = new MirButton();
        FishingButton->setIndex(1979);
        FishingButton->setHoverIndex(1980);
        FishingButton->setPressedIndex(1981);
        FishingButton->setParent(this);
        FishingButton->setLibrary(Libraries::Prguse);
        Point tempVar10(3, 164);
        FishingButton->setLocation(&tempVar10);
        FishingButton->setHint(std::string::Format(GameLanguage::Fishing, CMain::InputKeys->GetKey(KeybindOptions::Fishing)));
        FishingButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->FishingDialog->getVisible())
            {
                GameScene::Scene->FishingDialog->Hide();
            }
            else
            {
                GameScene::Scene->FishingDialog->Show();
            }
        };

        FriendButton = new MirButton();
        FriendButton->setIndex(1982);
        FriendButton->setHoverIndex(1983);
        FriendButton->setPressedIndex(1984);
        FriendButton->setParent(this);
        FriendButton->setLibrary(Libraries::Prguse);
        Point tempVar11(3, 183);
        FriendButton->setLocation(&tempVar11);
        FriendButton->setVisible(true);
        FriendButton->setHint(std::string::Format(GameLanguage::Friends, CMain::InputKeys->GetKey(KeybindOptions::Friends)));
        FriendButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->FriendDialog->getVisible())
            {
                GameScene::Scene->FriendDialog->Hide();
            }
            else
            {
                GameScene::Scene->FriendDialog->Show();
            }
        };

        MentorButton = new MirButton();
        MentorButton->setIndex(1985);
        MentorButton->setHoverIndex(1986);
        MentorButton->setPressedIndex(1987);
        MentorButton->setParent(this);
        MentorButton->setLibrary(Libraries::Prguse);
        Point tempVar12(3, 202);
        MentorButton->setLocation(&tempVar12);
        MentorButton->setVisible(true);
        MentorButton->setHint(std::string::Format(GameLanguage::Mentor, CMain::InputKeys->GetKey(KeybindOptions::Mentor)));
        MentorButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->MentorDialog->getVisible())
            {
                GameScene::Scene->MentorDialog->Hide();
            }
            else
            {
                GameScene::Scene->MentorDialog->Show();
            }
        };


        RelationshipButton = new MirButton();
        RelationshipButton->setIndex(1988);
        RelationshipButton->setHoverIndex(1989);
        RelationshipButton->setPressedIndex(1990);
        RelationshipButton->setParent(this);
        RelationshipButton->setLibrary(Libraries::Prguse);
        Point tempVar13(3, 221);
        RelationshipButton->setLocation(&tempVar13);
        RelationshipButton->setVisible(true);
        RelationshipButton->setHint(std::string::Format(GameLanguage::Relationship, CMain::InputKeys->GetKey(KeybindOptions::Relationship)));
        RelationshipButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->RelationshipDialog->getVisible())
            {
                GameScene::Scene->RelationshipDialog->Hide();
            }
            else
            {
                GameScene::Scene->RelationshipDialog->Show();
            }
        };

        GroupButton = new MirButton();
        GroupButton->setIndex(1991);
        GroupButton->setHoverIndex(1992);
        GroupButton->setPressedIndex(1993);
        GroupButton->setParent(this);
        GroupButton->setLibrary(Libraries::Prguse);
        Point tempVar14(3, 240);
        GroupButton->setLocation(&tempVar14);
        GroupButton->setHint(std::string::Format(GameLanguage::Groups, CMain::InputKeys->GetKey(KeybindOptions::Group)));
        GroupButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->GroupDialog->getVisible())
            {
                GameScene::Scene->GroupDialog->Hide();
            }
            else
            {
                GameScene::Scene->GroupDialog->Show();
            }
        };

        GuildButton = new MirButton();
        GuildButton->setIndex(1994);
        GuildButton->setHoverIndex(1995);
        GuildButton->setPressedIndex(1996);
        GuildButton->setParent(this);
        GuildButton->setLibrary(Libraries::Prguse);
        Point tempVar15(3, 259);
        GuildButton->setLocation(&tempVar15);
        GuildButton->setHint(std::string::Format(GameLanguage::Guild, CMain::InputKeys->GetKey(KeybindOptions::Guilds)));
        GuildButton->Click += [&] (o, e)
        {
            if (GameScene::Scene->GuildDialog->getVisible())
            {
                GameScene::Scene->GuildDialog->Hide();
            }
            else
            {
                GameScene::Scene->GuildDialog->Show();
            }
        };

    }

    MagicButton::MagicButton()
    {
        Size tempVar(231, 33);
        setSize(&tempVar);

        SkillButton = new MirButton();
        SkillButton->setIndex(0);
        SkillButton->setPressedIndex(1);
        SkillButton->setLibrary(Libraries::MagIcon2);
        SkillButton->setParent(this);
        Point tempVar2(36, 0);
        SkillButton->setLocation(&tempVar2);
        SkillButton->setSound(SoundList::ButtonA);
        SkillButton->Click += [&] (o, e)
        {
            return new AssignKeyPanel(Magic);
        };

        LevelImage = new MirImageControl();
        LevelImage->setIndex(516);
        LevelImage->setLibrary(Libraries::Title);
        Point tempVar3(73, 7);
        LevelImage->setLocation(&tempVar3);
        LevelImage->setParent(this);
        LevelImage->setNotControl(true);

        ExpImage = new MirImageControl();
        ExpImage->setIndex(517);
        ExpImage->setLibrary(Libraries::Title);
        Point tempVar4(73, 19);
        ExpImage->setLocation(&tempVar4);
        ExpImage->setParent(this);
        ExpImage->setNotControl(true);

        LevelLabel = new MirLabel();
        LevelLabel->setAutoSize(true);
        LevelLabel->setParent(this);
        Point tempVar5(88, 2);
        LevelLabel->setLocation(&tempVar5);
        LevelLabel->setNotControl(true);

        NameLabel = new MirLabel();
        NameLabel->setAutoSize(true);
        NameLabel->setParent(this);
        Point tempVar6(109, 2);
        NameLabel->setLocation(&tempVar6);
        NameLabel->setNotControl(true);

        ExpLabel = new MirLabel();
        ExpLabel->setAutoSize(true);
        ExpLabel->setParent(this);
        Point tempVar7(109, 15);
        ExpLabel->setLocation(&tempVar7);
        ExpLabel->setNotControl(true);

        KeyLabel = new MirLabel();
        KeyLabel->setAutoSize(true);
        KeyLabel->setParent(this);
        Point tempVar8(2, 2);
        KeyLabel->setLocation(&tempVar8);
        KeyLabel->setNotControl(true);

        CoolDown = new MirAnimatedControl();
        CoolDown->setLibrary(Libraries::Prguse2);
        CoolDown->setParent(this);
        Point tempVar9(36, 0);
        CoolDown->setLocation(&tempVar9);
        CoolDown->setNotControl(true);
        CoolDown->setUseOffSet(true);
        CoolDown->setLoop(false);
        CoolDown->setAnimated(false);
        CoolDown->setOpacity(0.6F);
    }

    void MagicButton::Update(ClientMagic *magic)
    {
        Magic = magic;

        NameLabel->setText(Magic->Name);

        LevelLabel->setText(std::to_string(Magic->Level));
        switch (Magic->Level)
        {
            case 0:
                ExpLabel->setText(StringHelper::formatSimple("{0}/{1}", Magic->Experience, Magic->Need1));
                break;
            case 1:
                ExpLabel->setText(StringHelper::formatSimple("{0}/{1}", Magic->Experience, Magic->Need2));
                break;
            case 2:
                ExpLabel->setText(StringHelper::formatSimple("{0}/{1}", Magic->Experience, Magic->Need3));
                break;
            case 3:
                ExpLabel->setText("-");
                break;
        }

        if (Magic->Key > 8)
        {
            int key = Magic->Key % 8;

            KeyLabel->setText(StringHelper::formatSimple("CTRL" + "\r\n" + "F{0}", key != 0 ? key : 8));
        }
        else if (Magic->Key > 0)
        {
            KeyLabel->setText(StringHelper::formatSimple("F{0}", Magic->Key));
        }
        else
        {
            KeyLabel->setText("");
        }


        SkillButton->setIndex(Magic->Icon * 2);
        SkillButton->setPressedIndex(Magic->Icon * 2 + 1);

        SetDelay();
    }

    void MagicButton::SetDelay()
    {
        if (Magic == nullptr)
        {
            return;
        }

        int totalFrames = 34;

        long long timeLeft = Magic->CastTime + Magic->Delay - CMain::Time;

        if (timeLeft < 100 || (CoolDown != nullptr && CoolDown->getAnimated()))
        {
            return;
        }

        int delayPerFrame = static_cast<int>(Magic->Delay / totalFrames);
        int startFrame = totalFrames - static_cast<int>(timeLeft / delayPerFrame);

        if ((CMain::Time <= Magic->CastTime + Magic->Delay) && Magic->CastTime > 0)
        {
            CoolDown->Dispose();

            CoolDown = new MirAnimatedControl();
            CoolDown->setIndex(1290 + startFrame);
            CoolDown->setAnimationCount((totalFrames - startFrame));
            CoolDown->setAnimationDelay(delayPerFrame);
            CoolDown->setLibrary(Libraries::Prguse2);
            CoolDown->setParent(this);
            Point tempVar(36, 0);
            CoolDown->setLocation(&tempVar);
            CoolDown->setNotControl(true);
            CoolDown->setUseOffSet(true);
            CoolDown->setLoop(false);
            CoolDown->setAnimated(true);
            CoolDown->setOpacity(0.6F);
        }
    }

    AssignKeyPanel::AssignKeyPanel(ClientMagic *magic)
    {
        Magic = magic;
        Key = magic->Key;

        setModal(true);
        setIndex(710);
        setLibrary(Libraries::Prguse);
        setLocation(getCenter());
        setParent(GameScene::Scene);
        setVisible(true);

        MagicImage = new MirImageControl();
        Point tempVar(16, 16);
        MagicImage->setLocation(&tempVar);
        MagicImage->setIndex(magic->Icon * 2);
        MagicImage->setLibrary(Libraries::MagIcon2);
        MagicImage->setParent(this);

        TitleLabel = new MirLabel();
        Point tempVar2(49, 17);
        TitleLabel->setLocation(&tempVar2);
        TitleLabel->setParent(this);
        Size tempVar3(230, 32);
        TitleLabel->setSize(&tempVar3);
        TitleLabel->setDrawFormat(TextFormatFlags::HorizontalCenter | TextFormatFlags::WordBreak);
        TitleLabel->setText(std::string::Format(GameLanguage::SelectKey, magic->Name));

        NoneButton = new MirButton();
        NoneButton->setIndex(287);
        NoneButton->setHoverIndex(288);
        NoneButton->setPressedIndex(289);
        NoneButton->setLibrary(Libraries::Title);
        NoneButton->setParent(this);
        Point tempVar4(284, 64);
        NoneButton->setLocation(&tempVar4);
        NoneButton->Click += [&] (o, e)
        {
            Key = 0;
        };

        SaveButton = new MirButton();
        SaveButton->setLibrary(Libraries::Title);
        SaveButton->setParent(this);
        Point tempVar5(284, 101);
        SaveButton->setLocation(&tempVar5);
        SaveButton->setIndex(156);
        SaveButton->setHoverIndex(157);
        SaveButton->setPressedIndex(158);
        SaveButton->Click += [&] (o, e)
        {
            for (int i = 0; i < MapObject::User->Magics.size(); i++)
            {
                if (MapObject::User->Magics[i]->Key == Key)
                {
                    MapObject::User->Magics[i]->Key = 0;
                }
            }
    
            C::MagicKey *tempVar6 = new C::MagicKey();
            tempVar6->Spell = Magic->Spell;
            tempVar6->Key = Key;
            Network::Enqueue(tempVar6);
            Magic->Key = Key;
            for (auto Bar : GameScene::Scene->SkillBarDialogs)
            {
                Bar->Update();
            }
    
            Dispose();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar6' statement was not added since tempVar6 was passed to a method or constructor. Handle memory management manually.
        };


        FKeys = std::vector<MirButton*>(16);

        MirButton *tempVar7 = new MirButton();
        tempVar7->setIndex(0);
        tempVar7->setPressedIndex(1);
        tempVar7->setLibrary(Libraries::Prguse);
        tempVar7->setParent(this);
        Point tempVar8(17, 58);
        tempVar7->setLocation(&tempVar8);
        tempVar7->setSound(SoundList::ButtonA);
        tempVar7->setText("F1");
        FKeys[0] = tempVar7;
        FKeys[0]->Click += [&] (o, e)
        {
            Key = 1;
        };

        MirButton *tempVar9 = new MirButton();
        tempVar9->setIndex(0);
        tempVar9->setPressedIndex(1);
        tempVar9->setLibrary(Libraries::Prguse);
        tempVar9->setParent(this);
        Point tempVar10(49, 58);
        tempVar9->setLocation(&tempVar10);
        tempVar9->setSound(SoundList::ButtonA);
        tempVar9->setText("F2");
        FKeys[1] = tempVar9;
        FKeys[1]->Click += [&] (o, e)
        {
            Key = 2;
        };

        MirButton *tempVar11 = new MirButton();
        tempVar11->setIndex(0);
        tempVar11->setPressedIndex(1);
        tempVar11->setLibrary(Libraries::Prguse);
        tempVar11->setParent(this);
        Point tempVar12(81, 58);
        tempVar11->setLocation(&tempVar12);
        tempVar11->setSound(SoundList::ButtonA);
        tempVar11->setText("F3");
        FKeys[2] = tempVar11;
        FKeys[2]->Click += [&] (o, e)
        {
            Key = 3;
        };

        MirButton *tempVar13 = new MirButton();
        tempVar13->setIndex(0);
        tempVar13->setPressedIndex(1);
        tempVar13->setLibrary(Libraries::Prguse);
        tempVar13->setParent(this);
        Point tempVar14(113, 58);
        tempVar13->setLocation(&tempVar14);
        tempVar13->setSound(SoundList::ButtonA);
        tempVar13->setText("F4");
        FKeys[3] = tempVar13;
        FKeys[3]->Click += [&] (o, e)
        {
            Key = 4;
        };

        MirButton *tempVar15 = new MirButton();
        tempVar15->setIndex(0);
        tempVar15->setPressedIndex(1);
        tempVar15->setLibrary(Libraries::Prguse);
        tempVar15->setParent(this);
        Point tempVar16(150, 58);
        tempVar15->setLocation(&tempVar16);
        tempVar15->setSound(SoundList::ButtonA);
        tempVar15->setText("F5");
        FKeys[4] = tempVar15;
        FKeys[4]->Click += [&] (o, e)
        {
            Key = 5;
        };

        MirButton *tempVar17 = new MirButton();
        tempVar17->setIndex(0);
        tempVar17->setPressedIndex(1);
        tempVar17->setLibrary(Libraries::Prguse);
        tempVar17->setParent(this);
        Point tempVar18(182, 58);
        tempVar17->setLocation(&tempVar18);
        tempVar17->setSound(SoundList::ButtonA);
        tempVar17->setText("F6");
        FKeys[5] = tempVar17;
        FKeys[5]->Click += [&] (o, e)
        {
            Key = 6;
        };

        MirButton *tempVar19 = new MirButton();
        tempVar19->setIndex(0);
        tempVar19->setPressedIndex(1);
        tempVar19->setLibrary(Libraries::Prguse);
        tempVar19->setParent(this);
        Point tempVar20(214, 58);
        tempVar19->setLocation(&tempVar20);
        tempVar19->setSound(SoundList::ButtonA);
        tempVar19->setText("F7");
        FKeys[6] = tempVar19;
        FKeys[6]->Click += [&] (o, e)
        {
            Key = 7;
        };

        MirButton *tempVar21 = new MirButton();
        tempVar21->setIndex(0);
        tempVar21->setPressedIndex(1);
        tempVar21->setLibrary(Libraries::Prguse);
        tempVar21->setParent(this);
        Point tempVar22(246, 58);
        tempVar21->setLocation(&tempVar22);
        tempVar21->setSound(SoundList::ButtonA);
        tempVar21->setText("F8");
        FKeys[7] = tempVar21;
        FKeys[7]->Click += [&] (o, e)
        {
            Key = 8;
        };


        MirButton *tempVar23 = new MirButton();
        tempVar23->setIndex(0);
        tempVar23->setPressedIndex(1);
        tempVar23->setLibrary(Libraries::Prguse);
        tempVar23->setParent(this);
        Point tempVar24(17, 95);
        tempVar23->setLocation(&tempVar24);
        tempVar23->setSound(SoundList::ButtonA);
        tempVar23->setText("Ctrl" + "\r\n" + "F1");
        FKeys[8] = tempVar23;
        FKeys[8]->Click += [&] (o, e)
        {
            Key = 9;
        };

        MirButton *tempVar25 = new MirButton();
        tempVar25->setIndex(0);
        tempVar25->setPressedIndex(1);
        tempVar25->setLibrary(Libraries::Prguse);
        tempVar25->setParent(this);
        Point tempVar26(49, 95);
        tempVar25->setLocation(&tempVar26);
        tempVar25->setSound(SoundList::ButtonA);
        tempVar25->setText("Ctrl" + "\r\n" + "F2");
        FKeys[9] = tempVar25;
        FKeys[9]->Click += [&] (o, e)
        {
            Key = 10;
        };

        MirButton *tempVar27 = new MirButton();
        tempVar27->setIndex(0);
        tempVar27->setPressedIndex(1);
        tempVar27->setLibrary(Libraries::Prguse);
        tempVar27->setParent(this);
        Point tempVar28(81, 95);
        tempVar27->setLocation(&tempVar28);
        tempVar27->setSound(SoundList::ButtonA);
        tempVar27->setText("Ctrl" + "\r\n" + "F3");
        FKeys[10] = tempVar27;
        FKeys[10]->Click += [&] (o, e)
        {
            Key = 11;
        };

        MirButton *tempVar29 = new MirButton();
        tempVar29->setIndex(0);
        tempVar29->setPressedIndex(1);
        tempVar29->setLibrary(Libraries::Prguse);
        tempVar29->setParent(this);
        Point tempVar30(113, 95);
        tempVar29->setLocation(&tempVar30);
        tempVar29->setSound(SoundList::ButtonA);
        tempVar29->setText("Ctrl" + "\r\n" + "F4");
        FKeys[11] = tempVar29;
        FKeys[11]->Click += [&] (o, e)
        {
            Key = 12;
        };

        MirButton *tempVar31 = new MirButton();
        tempVar31->setIndex(0);
        tempVar31->setPressedIndex(1);
        tempVar31->setLibrary(Libraries::Prguse);
        tempVar31->setParent(this);
        Point tempVar32(150, 95);
        tempVar31->setLocation(&tempVar32);
        tempVar31->setSound(SoundList::ButtonA);
        tempVar31->setText("Ctrl" + "\r\n" + "F5");
        FKeys[12] = tempVar31;
        FKeys[12]->Click += [&] (o, e)
        {
            Key = 13;
        };

        MirButton *tempVar33 = new MirButton();
        tempVar33->setIndex(0);
        tempVar33->setPressedIndex(1);
        tempVar33->setLibrary(Libraries::Prguse);
        tempVar33->setParent(this);
        Point tempVar34(182, 95);
        tempVar33->setLocation(&tempVar34);
        tempVar33->setSound(SoundList::ButtonA);
        tempVar33->setText("Ctrl" + "\r\n" + "F6");
        FKeys[13] = tempVar33;
        FKeys[13]->Click += [&] (o, e)
        {
            Key = 14;
        };

        MirButton *tempVar35 = new MirButton();
        tempVar35->setIndex(0);
        tempVar35->setPressedIndex(1);
        tempVar35->setLibrary(Libraries::Prguse);
        tempVar35->setParent(this);
        Point tempVar36(214, 95);
        tempVar35->setLocation(&tempVar36);
        tempVar35->setSound(SoundList::ButtonA);
        tempVar35->setText("Ctrl" + "\r\n" + "F7");
        FKeys[14] = tempVar35;
        FKeys[14]->Click += [&] (o, e)
        {
            Key = 15;
        };

        MirButton *tempVar37 = new MirButton();
        tempVar37->setIndex(0);
        tempVar37->setPressedIndex(1);
        tempVar37->setLibrary(Libraries::Prguse);
        tempVar37->setParent(this);
        Point tempVar38(246, 95);
        tempVar37->setLocation(&tempVar38);
        tempVar37->setSound(SoundList::ButtonA);
        tempVar37->setText("Ctrl" + "\r\n" + "F8");
        FKeys[15] = tempVar37;
        FKeys[15]->Click += [&] (o, e)
        {
            Key = 16;
        };

        BeforeDraw += AssignKeyPanel_BeforeDraw;

        delete tempVar37;
        delete tempVar35;
        delete tempVar33;
        delete tempVar31;
        delete tempVar29;
        delete tempVar27;
        delete tempVar25;
        delete tempVar23;
        delete tempVar21;
        delete tempVar19;
        delete tempVar17;
        delete tempVar15;
        delete tempVar13;
        delete tempVar11;
        delete tempVar9;
        delete tempVar7;
    }

    void AssignKeyPanel::AssignKeyPanel_BeforeDraw(std::any sender, EventArgs *e)
    {
        for (int i = 0; i < FKeys.size(); i++)
        {
            FKeys[i]->setIndex(1656);
            FKeys[i]->setHoverIndex(1657);
            FKeys[i]->setPressedIndex(1658);
            FKeys[i]->setVisible(true);
        }

        if (Key == 0 || Key > FKeys.size())
        {
            return;
        }

        FKeys[Key - 1]->setIndex(1658);
        FKeys[Key - 1]->setHoverIndex(1658);
        FKeys[Key - 1]->setPressedIndex(1658);
    }

    BigMapDialog::BigMapDialog()
    {
        setNotControl(false);
        Point tempVar(130, 100);
        setLocation(&tempVar);
        //Border = true;
        //BorderColour = Color.Lime;
        BeforeDraw += [&] (o, e)
        {
            OnBeforeDraw();
        };
        setSort(true);

        MouseMove += UpdateBigMapCoordinates;
    }

    void BigMapDialog::UpdateBigMapCoordinates(std::any sender, MouseEventArgs *e)
    {
            int MouseCoordsOnBigMap_MapValue_X = static_cast<int>((e->Location->X - BigMap_MouseCoordsProcessing_OffsetX) / ScaleX);
            int MouseCoordsOnBigMap_MapValue_Y = static_cast<int>((e->Location->Y - BigMap_MouseCoordsProcessing_OffsetY) / ScaleY);

            this->setHint(StringHelper::formatSimple("{0},{1}", MouseCoordsOnBigMap_MapValue_X, MouseCoordsOnBigMap_MapValue_Y));
    }

    void BigMapDialog::OnBeforeDraw()
    {
        MapControl *map = GameScene::Scene->MapControl;
        if (map == nullptr || !getVisible())
        {
            return;
        }

        //int index = map.BigMap <= 0 ? map.MiniMap : map.BigMap;
        int index = map->BigMap;

        if (index <= 0)
        {
            if (getVisible())
            {
                setVisible(false);
            }
            return;
        }

        TrySort();

        Rectangle *viewRect = new Rectangle(0, 0, 600, 400);

        setSize(Libraries::MiniMap->GetSize(index));

        if (getSize()->Width < 600)
        {
            viewRect->Width = getSize()->Width;
        }

        if (getSize()->Height < 400)
        {
            viewRect->Height = getSize()->Height;
        }

        viewRect->X = (Settings::ScreenWidth - viewRect->Width) / 2;
        viewRect->Y = (Settings::ScreenHeight - 120 - viewRect->Height) / 2;

    BigMap_MouseCoordsProcessing_OffsetX = viewRect->X;
        BigMap_MouseCoordsProcessing_OffsetY = viewRect->Y;

        setLocation(viewRect->Location);
        setSize(viewRect->Size);

        ScaleX = getSize()->Width / static_cast<float>(map->Width);
        ScaleY = getSize()->Height / static_cast<float>(map->Height);

        viewRect->Location = new Point(static_cast<int>(ScaleX * MapObject::User->CurrentLocation->X) - viewRect->Width / 2, static_cast<int>(ScaleY * MapObject::User->CurrentLocation->Y) - viewRect->Height / 2);

        if (viewRect->Right >= getSize()->Width)
        {
            viewRect->X = getSize()->Width - viewRect->Width;
        }
        if (viewRect->Bottom >= getSize()->Height)
        {
            viewRect->Y = getSize()->Height - viewRect->Height;
        }

        if (viewRect->X < 0)
        {
            viewRect->X = 0;
        }
        if (viewRect->Y < 0)
        {
            viewRect->Y = 0;
        }

        Libraries::MiniMap->Draw(index, getLocation(), getSize(), Color::FromArgb(255, 255, 255));

        int startPointX = static_cast<int>(viewRect->X / ScaleX);
        int startPointY = static_cast<int>(viewRect->Y / ScaleY);

        for (int i = MapControl::Objects.size() - 1; i >= 0; i--)
        {
            MapObject *ob = MapControl::Objects[i];


            if (ob->getRace() == ObjectType::Item || ob->Dead || ob->getRace() == ObjectType::Spell)
            {
                continue; // || (ob.ObjectID != MapObject.User.ObjectID)
            }
            float x = ((ob->CurrentLocation->X - startPointX) * ScaleX) + getLocation()->X;
            float y = ((ob->CurrentLocation->Y - startPointY) * ScaleY) + getLocation()->Y;

            Color *colour;

            if ((std::find(GroupDialog::GroupList.begin(), GroupDialog::GroupList.end(), ob->Name) != GroupDialog::GroupList.end() && MapObject::User != ob) || ob->Name.EndsWith(StringHelper::formatSimple("({0})", MapObject::User->Name)))
            {
                colour = Color::FromArgb(0, 0, 255);
            }
            else
            {
                if (dynamic_cast<PlayerObject*>(ob) != nullptr)
                {
                colour = Color::FromArgb(255, 255, 255);
                }
            else if (dynamic_cast<NPCObject*>(ob) != nullptr || ob->AI == 6)
            {
                colour = Color::FromArgb(0, 255, 50);
            }
            else
            {
                colour = Color::FromArgb(255, 0, 0);
            }
            }

            Rectangle tempVar(0, 0, 2, 2);
            Vector3 tempVar2(static_cast<float>(x - 0.5), static_cast<float>(y - 0.5), 0.0F);
            DXManager::Sprite->Draw(DXManager::RadarTexture, &tempVar, Vector3::Zero, &tempVar2, colour);
        }

        delete viewRect;
    }

    void BigMapDialog::Toggle()
    {
        setVisible(!getVisible());

        Redraw();
    }

    DuraStatusDialog::DuraStatusDialog()
    {
        Size tempVar(40, 19);
        setSize(&tempVar);
        Point tempVar2((GameScene::Scene->MiniMapDialog->getLocation()->X + 86), GameScene::Scene->MiniMapDialog->getSize()->Height);
        setLocation(&tempVar2);

        Character = new MirButton();
        Character->setIndex(2113);
        Character->setLibrary(Libraries::Prguse);
        Character->setParent(this);
        Size tempVar3(20, 19);
        Character->setSize(&tempVar3);
        Point tempVar4(20, 0);
        Character->setLocation(&tempVar4);
        Character->setHoverIndex(2111);
        Character->setPressedIndex(2112);
        Character->setSound(SoundList::ButtonA);
        Character->setHint(GameLanguage::DuraPanel);
        Character->Click += [&] (o, e)
        {
            if (GameScene::Scene->CharacterDuraPanel->getVisible() == true)
            {
                GameScene::Scene->CharacterDuraPanel->Hide();
                Settings::DuraView = false;
            }
            else
            {
                GameScene::Scene->CharacterDuraPanel->Show();
                Settings::DuraView = true;
            }
        };
    }

    CharacterDuraPanel::CharacterDuraPanel()
    {
        setIndex(2105);
        setLibrary(Libraries::Prguse);
        setMovable(false);
        Point tempVar(Settings::ScreenWidth - 61, 200);
        setLocation(&tempVar);

        GrayBackground = new MirImageControl();
        GrayBackground->setIndex(2161);
        GrayBackground->setLibrary(Libraries::Prguse);
        GrayBackground->setParent(this);
        Size tempVar2(56, 80);
        GrayBackground->setSize(&tempVar2);
        Point tempVar3(3, 3);
        GrayBackground->setLocation(&tempVar3);
        GrayBackground->setOpacity(0.4F);
        Background = new MirImageControl();
        Background->setIndex(2162);
        Background->setLibrary(Libraries::Prguse);
        Background->setParent(this);
        Size tempVar4(56, 80);
        Background->setSize(&tempVar4);
        Point tempVar5(3, 3);
        Background->setLocation(&tempVar5);

        #pragma region Pieces

        Helmet = new MirImageControl();
        Helmet->setIndex(-1);
        Helmet->setLibrary(Libraries::Prguse);
        Helmet->setParent(Background);
        Size tempVar6(12, 12);
        Helmet->setSize(&tempVar6);
        Point tempVar7(24, 3);
        Helmet->setLocation(&tempVar7);
        Belt = new MirImageControl();
        Belt->setIndex(-1);
        Belt->setLibrary(Libraries::Prguse);
        Belt->setParent(Background);
        Size tempVar8(12, 7);
        Belt->setSize(&tempVar8);
        Point tempVar9(23, 23);
        Belt->setLocation(&tempVar9);
        Armour = new MirImageControl();
        Armour->setIndex(-1);
        Armour->setLibrary(Libraries::Prguse);
        Armour->setParent(Background);
        Size tempVar10(28, 32);
        Armour->setSize(&tempVar10);
        Point tempVar11(16, 11);
        Armour->setLocation(&tempVar11);
        Boots = new MirImageControl();
        Boots->setIndex(-1);
        Boots->setLibrary(Libraries::Prguse);
        Boots->setParent(Background);
        Size tempVar12(24, 9);
        Boots->setSize(&tempVar12);
        Point tempVar13(17, 43);
        Boots->setLocation(&tempVar13);
        Weapon = new MirImageControl();
        Weapon->setIndex(-1);
        Weapon->setLibrary(Libraries::Prguse);
        Weapon->setParent(Background);
        Size tempVar14(12, 33);
        Weapon->setSize(&tempVar14);
        Point tempVar15(4, 5);
        Weapon->setLocation(&tempVar15);
        Necklace = new MirImageControl();
        Necklace->setIndex(-1);
        Necklace->setLibrary(Libraries::Prguse);
        Necklace->setParent(Background);
        Size tempVar16(12, 12);
        Necklace->setSize(&tempVar16);
        Point tempVar17(3, 67);
        Necklace->setLocation(&tempVar17);
        LeftBracelet = new MirImageControl();
        LeftBracelet->setIndex(-1);
        LeftBracelet->setLibrary(Libraries::Prguse);
        LeftBracelet->setParent(Background);
        Size tempVar18(12, 8);
        LeftBracelet->setSize(&tempVar18);
        Point tempVar19(3, 43);
        LeftBracelet->setLocation(&tempVar19);
        RightBracelet = new MirImageControl();
        RightBracelet->setIndex(-1);
        RightBracelet->setLibrary(Libraries::Prguse);
        RightBracelet->setParent(Background);
        Size tempVar20(12, 8);
        RightBracelet->setSize(&tempVar20);
        Point tempVar21(43, 43);
        RightBracelet->setLocation(&tempVar21);
        LeftRing = new MirImageControl();
        LeftRing->setIndex(-1);
        LeftRing->setLibrary(Libraries::Prguse);
        LeftRing->setParent(Background);
        Size tempVar22(12, 12);
        LeftRing->setSize(&tempVar22);
        Point tempVar23(3, 54);
        LeftRing->setLocation(&tempVar23);
        RightRing = new MirImageControl();
        RightRing->setIndex(-1);
        RightRing->setLibrary(Libraries::Prguse);
        RightRing->setParent(Background);
        Size tempVar24(12, 12);
        RightRing->setSize(&tempVar24);
        Point tempVar25(43, 54);
        RightRing->setLocation(&tempVar25);
        Torch = new MirImageControl();
        Torch->setIndex(-1);
        Torch->setLibrary(Libraries::Prguse);
        Torch->setParent(Background);
        Size tempVar26(8, 32);
        Torch->setSize(&tempVar26);
        Point tempVar27(44, 5);
        Torch->setLocation(&tempVar27);
        Stone = new MirImageControl();
        Stone->setIndex(-1);
        Stone->setLibrary(Libraries::Prguse);
        Stone->setParent(Background);
        Size tempVar28(12, 12);
        Stone->setSize(&tempVar28);
        Point tempVar29(30, 54);
        Stone->setLocation(&tempVar29);
        Amulet = new MirImageControl();
        Amulet->setIndex(-1);
        Amulet->setLibrary(Libraries::Prguse);
        Amulet->setParent(Background);
        Size tempVar30(12, 12);
        Amulet->setSize(&tempVar30);
        Point tempVar31(16, 54);
        Amulet->setLocation(&tempVar31);
        Mount = new MirImageControl();
        Mount->setIndex(-1);
        Mount->setLibrary(Libraries::Prguse);
        Mount->setParent(Background);
        Size tempVar32(12, 12);
        Mount->setSize(&tempVar32);
        Point tempVar33(43, 68);
        Mount->setLocation(&tempVar33);
        Item1 = new MirImageControl();
        Item1->setIndex(-1);
        Item1->setLibrary(Libraries::Prguse);
        Item1->setParent(Background);
        Size tempVar34(8, 12);
        Item1->setSize(&tempVar34);
        Point tempVar35(19, 67);
        Item1->setLocation(&tempVar35);
        Item2 = new MirImageControl();
        Item2->setIndex(-1);
        Item2->setLibrary(Libraries::Prguse);
        Item2->setParent(Background);
        Size tempVar36(8, 12);
        Item2->setSize(&tempVar36);
        Point tempVar37(31, 67);
        Item2->setLocation(&tempVar37);

        #pragma endregion
    }

    void CharacterDuraPanel::GetCharacterDura()
    {
        if (GameScene::Scene->CharacterDialog->Grid[0]->getItem() == nullptr)
        {
            Weapon->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[1]->getItem() == nullptr)
        {
            Armour->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[2]->getItem() == nullptr)
        {
            Helmet->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[3]->getItem() == nullptr)
        {
            Torch->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[4]->getItem() == nullptr)
        {
            Necklace->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[5]->getItem() == nullptr)
        {
            LeftBracelet->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[6]->getItem() == nullptr)
        {
            RightBracelet->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[7]->getItem() == nullptr)
        {
            LeftRing->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[8]->getItem() == nullptr)
        {
            RightRing->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[9]->getItem() == nullptr)
        {
            Amulet->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[10]->getItem() == nullptr)
        {
            Belt->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[11]->getItem() == nullptr)
        {
            Boots->setIndex(-1);
        }
        if (GameScene::Scene->CharacterDialog->Grid[12]->getItem() == nullptr)
        {
            Stone->setIndex(-1);
        }

        for (int i = 0; i < MapObject::User->Equipment.size(); i++)
        {
            if (MapObject::User->Equipment[i] == nullptr)
            {
                continue;
            }
            UpdateCharacterDura(MapObject::User->Equipment[i]);
        }
    }

    void CharacterDuraPanel::UpdateCharacterDura(UserItem *item)
    {
        int Warning = item->MaxDura / 2;
        int Danger = item->MaxDura / 5;
        unsigned short AmuletWarning = static_cast<unsigned short>(item->Info->StackSize / 2);
        unsigned short AmuletDanger = static_cast<unsigned short>(item->Info->StackSize / 5);

        switch (item->Info->Type)
        {
            case ItemType::Amulet: //Based on stacks of 5000
                if (item->Count > AmuletWarning)
                {
                    Amulet->setIndex(2134);
                }
                if (item->Count <= AmuletWarning)
                {
                    Amulet->setIndex(2135);
                }
                if (item->Count <= AmuletDanger)
                {
                    Amulet->setIndex(2136);
                }
                if (item->Count == 0)
                {
                    Amulet->setIndex(-1);
                }
                break;
            case ItemType::Armour:
                if (item->CurrentDura > Warning)
                {
                    Armour->setIndex(2149);
                }
                if (item->CurrentDura <= Warning)
                {
                    Armour->setIndex(2150);
                }
                if (item->CurrentDura <= Danger)
                {
                    Armour->setIndex(2151);
                }
                if (item->CurrentDura == 0)
                {
                    Armour->setIndex(-1);
                }
                break;
            case ItemType::Belt:
                if (item->CurrentDura > Warning)
                {
                    Belt->setIndex(2158);
                }
                if (item->CurrentDura <= Warning)
                {
                    Belt->setIndex(2159);
                }
                if (item->CurrentDura <= Danger)
                {
                    Belt->setIndex(2160);
                }
                if (item->CurrentDura == 0)
                {
                    Belt->setIndex(-1);
                }
                break;
            case ItemType::Boots:
                if (item->CurrentDura > Warning)
                {
                    Boots->setIndex(2152);
                }
                if (item->CurrentDura <= Warning)
                {
                    Boots->setIndex(2153);
                }
                if (item->CurrentDura <= Danger)
                {
                    Boots->setIndex(2154);
                }
                if (item->CurrentDura == 0)
                {
                    Boots->setIndex(-1);
                }
                break;
            case ItemType::Bracelet:
                if (GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::BraceletR)]->getItem() != nullptr && item->UniqueID == GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::BraceletR)]->getItem().UniqueID)
                {
                    if (item->CurrentDura > Warning)
                    {
                        RightBracelet->setIndex(2143);
                    }
                    if (item->CurrentDura <= Warning)
                    {
                        RightBracelet->setIndex(2144);
                    }
                    if (item->CurrentDura <= Danger)
                    {
                        RightBracelet->setIndex(2145);
                    }
                    if (item->CurrentDura == 0)
                    {
                        RightBracelet->setIndex(-1);
                    }
                }
                else if (GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::BraceletL)]->getItem() != nullptr && item->UniqueID == GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::BraceletL)]->getItem().UniqueID)
                {
                    if (item->CurrentDura > Warning)
                    {
                        LeftBracelet->setIndex(2143);
                    }
                    if (item->CurrentDura <= Warning)
                    {
                        LeftBracelet->setIndex(2144);
                    }
                    if (item->CurrentDura <= Danger)
                    {
                        LeftBracelet->setIndex(2145);
                    }
                    if (item->CurrentDura == 0)
                    {
                        LeftBracelet->setIndex(-1);
                    }
                }
                break;
            case ItemType::Helmet:
                if (item->CurrentDura > Warning)
                {
                    Helmet->setIndex(2155);
                }
                if (item->CurrentDura <= Warning)
                {
                    Helmet->setIndex(2156);
                }
                if (item->CurrentDura <= Danger)
                {
                    Helmet->setIndex(2157);
                }
                if (item->CurrentDura == 0)
                {
                    Helmet->setIndex(-1);
                }
                break;
            case ItemType::Necklace:
                if (item->CurrentDura > Warning)
                {
                    Necklace->setIndex(2122);
                }
                if (item->CurrentDura <= Warning)
                {
                    Necklace->setIndex(2123);
                }
                if (item->CurrentDura <= Danger)
                {
                    Necklace->setIndex(2124);
                }
                if (item->CurrentDura == 0)
                {
                    Necklace->setIndex(-1);
                }
                break;
            case ItemType::Ring:
                if (GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::RingR)]->getItem() != nullptr && item->UniqueID == GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::RingR)]->getItem().UniqueID)
                {
                    if (item->CurrentDura > Warning)
                    {
                        RightRing->setIndex(2131);
                    }
                    if (item->CurrentDura <= Warning)
                    {
                        RightRing->setIndex(2132);
                    }
                    if (item->CurrentDura <= Danger)
                    {
                        RightRing->setIndex(2133);
                    }
                    if (item->CurrentDura == 0)
                    {
                        RightRing->setIndex(-1);
                    }
                }
                else if (GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::RingL)]->getItem() != nullptr && item->UniqueID == GameScene::Scene->CharacterDialog->Grid[static_cast<unsigned char>(EquipmentSlot::RingL)]->getItem().UniqueID)
                {
                    if (item->CurrentDura > Warning)
                    {
                        LeftRing->setIndex(2131);
                    }
                    if (item->CurrentDura <= Warning)
                    {
                        LeftRing->setIndex(2132);
                    }
                    if (item->CurrentDura <= Danger)
                    {
                        LeftRing->setIndex(2133);
                    }
                    if (item->CurrentDura == 0)
                    {
                        LeftRing->setIndex(-1);
                    }
                }
                break;
            case ItemType::Stone:
                if (item->CurrentDura == 0)
                {
                    Stone->setIndex(2137);
                }
                break;
            case ItemType::Mount:
                if (item->CurrentDura > Warning)
                {
                    Mount->setIndex(2140);
                }
                if (item->CurrentDura <= Warning)
                {
                    Mount->setIndex(2141);
                }
                if (item->CurrentDura <= Danger)
                {
                    Mount->setIndex(2142);
                }
                if (item->CurrentDura == 0)
                {
                    Mount->setIndex(-1);
                }
                break;
            case ItemType::Torch:
                if (item->CurrentDura > Warning)
                {
                    Torch->setIndex(2146);
                }
                if (item->CurrentDura <= Warning)
                {
                    Torch->setIndex(2147);
                }
                if (item->CurrentDura <= Danger)
                {
                    Torch->setIndex(2148);
                }
                if (item->CurrentDura == 0)
                {
                    Torch->setIndex(-1);
                }
                break;
            case ItemType::Weapon:
                if (item->CurrentDura > Warning)
                {
                    Weapon->setIndex(2125);
                }
                if (item->CurrentDura <= Warning)
                {
                    Weapon->setIndex(2126);
                }
                if (item->CurrentDura <= Danger)
                {
                    Weapon->setIndex(2127);
                }
                if (item->CurrentDura == 0)
                {
                    Weapon->setIndex(-1);
                }
                break;
        }
    }

    void CharacterDuraPanel::Hide()
    {
        if (!getVisible())
        {
            return;
        }
        setVisible(false);
        GameScene::Scene->DuraStatusPanel->Character->setIndex(2113);
    }

    void CharacterDuraPanel::Show()
    {
        if (getVisible())
        {
            return;
        }
        setVisible(true);
        GameScene::Scene->DuraStatusPanel->Character->setIndex(2110);

        GetCharacterDura();
    }

    CustomPanel1::CustomPanel1(MirControl *parent)
    {
        setIndex(2179);
        setLibrary(Libraries::Prguse);
        Size tempVar(24, 61);
        setSize(&tempVar);
        setParent(parent);

        Point tempVar2(((Settings::ScreenWidth / 2) - (getSize()->Width / 2)) + 362, Settings::ScreenHeight - getSize()->Height - 77);
        setLocation(&tempVar2);

        Button1 = new MirButton();
        Button1->setIndex(2173);
        Button1->setHoverIndex(2174);
        Button1->setPressedIndex(2175);
        Button1->setLibrary(Libraries::Prguse);
        Button1->setParent(this);
        Size tempVar3(16, 16);
        Button1->setSize(&tempVar3);
        Point tempVar4(3, 3);
        Button1->setLocation(&tempVar4);
        Button1->setHint("SkillMode");
        Button1->Click += [&] (o, e)
        {
            GameScene::Scene->ChangeSkillMode(std::nullopt);
        };

        Button2 = new MirButton();
        Button2->setIndex(2170);
        Button2->setHoverIndex(2171);
        Button2->setPressedIndex(2172);
        Button2->setLibrary(Libraries::Prguse);
        Button2->setParent(this);
        Size tempVar5(16, 16);
        Button2->setSize(&tempVar5);
        Point tempVar6(3, 20);
        Button2->setLocation(&tempVar6);
        Button2->setHint("PetMode");
        Button2->Click += [&] (o, e)
        {
            GameScene::Scene->ChangePetMode();
        };

        Button3 = new MirButton();
        Button3->setIndex(2176);
        Button3->setHoverIndex(2177);
        Button3->setPressedIndex(2178);
        Button3->setLibrary(Libraries::Prguse);
        Button3->setParent(this);
        Size tempVar7(16, 16);
        Button3->setSize(&tempVar7);
        Point tempVar8(3, 37);
        Button3->setLocation(&tempVar8);
        Button3->setHint("AttackMode");
        Button3->Click += [&] (o, e)
        {
            GameScene::Scene->ChangeAttackMode();
        };
    }

    void CustomPanel1::Process()
    {
        switch (GameScene::Scene->AMode)
        {
            case AttackMode::Peace:
                AMode = "[Mode: Peaceful]";
                break;
            case AttackMode::Group:
                AMode = "[Mode: Group]";
                break;
            case AttackMode::Guild:
                AMode = "[Mode: Guild]";
                break;
            case AttackMode::EnemyGuild:
                AMode = "[Mode: Enemy Guild]";
                break;
            case AttackMode::RedBrown:
                AMode = "[Mode: Red/Brown]";
                break;
            case AttackMode::All:
                AMode = "[Mode: Attack All]";
                break;
        }

        switch (GameScene::Scene->PMode)
        {
            case PetMode::Both:
                PMode = "[Mode: Attack and Move]";
                break;
            case PetMode::MoveOnly:
                PMode = "[Mode: Do Not Attack]";
                break;
            case PetMode::AttackOnly:
                PMode = "[Mode: Do Not Move]";
                break;
            case PetMode::None:
                PMode = "[Mode: Do Not Attack or Move]";
                break;
        }

        switch (Settings::SkillMode)
        {
            case true:
                SMode = "[Mode: ~]";
                break;
            case false:
                SMode = "[Mode: Ctrl]";
                break;
        }

        //GameScene.Scene.MiniMapDialog.AModeLabel.Text = AMode;
        //GameScene.Scene.MiniMapDialog.PModeLabel.Text = PMode;
        //GameScene.Scene.MiniMapDialog.SModeLabel.Text = SMode;

        Button1->setHint(StringHelper::formatSimple("Skill Mode\r\n{0}", SMode));
        Button2->setHint(StringHelper::formatSimple("Pet Mode ({1})\r\n{0}", PMode, CMain::InputKeys->GetKey(KeybindOptions::ChangePetmode)));
        Button3->setHint(StringHelper::formatSimple("Attack Mode ({1})\r\n{0}", AMode, CMain::InputKeys->GetKey(KeybindOptions::ChangeAttackmode)));
    }

    void CustomPanel1::Toggle()
    {
        setVisible(!getVisible());
    }
}
